Closed Thread Icon

Topic awaiting preservation: how to do Apache subdomains... (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=25959" title="Pages that link to Topic awaiting preservation: how to do Apache subdomains... (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: how to do Apache subdomains... <span class="small">(Page 1 of 1)</span>\

 
robur
Nervous Wreck (II) Inmate

From: Careywood, Idaho, USA
Insane since: Jan 2005

posted posted 06-04-2005 18:13

Hello everyone!

I have Apache running locally on my computer so I can test my website offline.
What I want to do is set it up with subdomains.
Perferrably, they will work automatically: I won't have to tell apache that scientia.mydomain goes to mydomain/scientia, and safarri.mydomain goes to mydomain/safarri. I would rather that $x.mydomain goes to mydomain/$x, if you know what I mean.

I have played around with the virtualhost think, but to no success...

I would be glad if anyone could explain how to do this!

Thank you!

-Robur

robur
Nervous Wreck (II) Inmate

From: Careywood, Idaho, USA
Insane since: Jan 2005

posted posted 06-04-2005 18:51

I thought I might clarify my particular configuration;

at the bottom of my httpd.conf file, I have these lines:

code:
#BEGIN REDIRECT ALL REQUESTS TO THE ATI SERVER
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*) /users/aubrey/sites/atiserver/atiserver.php [nc]
</IfModule>
#END REDIRECT ALL REQUESTS TO THE ATI SERVER



It uses mod_rewrite to sent all incoming requests to my atiserver.php file, where they are processed.

The problem I am having is that for some reason, safarri.localhost does not get sent to my atiserver.php file. when I type it in in my browser, it says the file could not be found.
What I want to is somehow instruct Apache to procedd subdomain requests.

Suggestions appreciated,

-Robur

robur
Nervous Wreck (II) Inmate

From: Careywood, Idaho, USA
Insane since: Jan 2005

posted posted 06-05-2005 02:45

AAHAHh!!1

The problem had nothing to do with Apache.

After reading this tutorial (which took my forever to find :-), I was able to get everything working perfectly.

Hope this helps someone else:
http://www.evolt.org/MacOSX_vhosts/

-Robur

jiblet
Paranoid (IV) Inmate

From: Minneapolis
Insane since: May 2000

posted posted 06-06-2005 17:53

Actually I just set up vhosts on my laptop so I could get some work done Internet-free over the weekend. I chose to use ports instead of setting up local domain information. So I made my Sites directory the default, and put an index.php file links to all the port-based sites I had set up (which I simply made subdirectories of Sites). Perhaps a less elegant solution, but I prefer to keep everything in the httpd.conf where I'm used to it.

-jiblet

Epete05
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Jul 2005

posted posted 07-07-2005 03:26

Now lets give even the folks with a windows based server setup a chance.

Open up The HOSTS file @ Computer > C > WINDOWS > System 32 > drivers > etc > hosts
use notepad or your favorite text editor...
you will see

"127.0.0.1 localhost"

on the bottom line... this takes requests for localhosts and points them to 127.0.0.1
now all you need to do is set it up for the subdomain for your site, for example a gaming section would look like this:

"127.0.0.1 games.localhost"

without the quotes of course. Add in all the hosts you desire then open up you apache httpd.conf file

scroll all the way down til you see the virtual hosts part, for now everything should be commented out. For our example we need to add these lines of code to get the subdomain to completely work:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/Server/wwwroot"
</VirtualHost>

<VirtualHost *:80>
ServerName games.localhost
DocumentRoot "C:/Server/wwwroot/games"
</VirtualHost>

DO NOT FORGET THE FIRST LINE: 'NameVirtualHost *:80' Without it nothing will work... I learned this the hard way = )

Have fun, reply if any questions

« BackwardsOnwards »

Show Forum Drop Down Menu