Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

local development - setting site root for each site directory

Status
Not open for further replies.

vvez

Programmer
Joined
Aug 2, 2004
Messages
1
Location
AU
Hey Guys

When developing locally im wanting to set the root for each site. Currently i have to refer to links as /sitefoldername/images, instead of /images as with my remote host. I need to use absolute links as im using mod_rewrite

I also require others to have access over the lan. I have used vhosts to do it, and it works on my machine (where apache runs) but others couldn't access over the lan, and i dont want to change the hosts file on each.

eg.. httpd.conf
<VirtualHost 127.0.0.1>
ServerName sitename.dev
DocumentRoot "c:/root/dev"
RewriteEngine on
RewriteRule ^/([a-z]+)$ /index.php?page=$1
</VirtualHost>
hosts file
127.0.0.1 sitename.dev

I also tried updating the root when in the site folder
eg - sitefolder/.htaccess...
DocumentRoot "c:/root/site folder"
But gives internal errors, is it possible to do it this way??

Ideally i just want to be able to access localhost(or my computer name)/sitename and have the root as the sitename folder.

There must be an easy way to do this

Any ideas??

Thanks

xp pro
apache 2.0.4.7
php 4.3.3
 
DocumentRoot can not be defined in .htaccess

Instead of using localhost use the IP address of the machine. The IP is only 127.0.0.1 when you are actually logged into it. When others log in it needs to be set to what they connect to.

SO this format

<VirtualHost 127.0.0.1>
ServerName sitename.dev
DocumentRoot "c:/root/dev"
RewriteEngine on
RewriteRule ^/([a-z]+)$ /index.php?page=$1
</VirtualHost>


is ok, just change 127.0.0.1 to your actual IP.

Then, to have additional vhosts setup dns for each one and change ServerName to that dns entry. So you would have


<VirtualHost YOURIP>
ServerName DocumentRoot "c:/root/site"
RewriteEngine on
RewriteRule ^/([a-z]+)$ /index.php?page=$1
</VirtualHost>

<VirtualHost YOURIP>
ServerName DocumentRoot "c:/root/site1"
RewriteEngine on
RewriteRule ^/([a-z]+)$ /index.php?page=$1
</VirtualHost>

<VirtualHost YOURIP>
ServerName DocumentRoot "c:/root/site2"
RewriteEngine on
RewriteRule ^/([a-z]+)$ /index.php?page=$1
</VirtualHost>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top