Take the 2-minute tour ×

I have a development box which contains my site in:


My production environment is just:


I have all my PHP scripts adjusting to different paths automatically, but everytime I upload changes to my .htaccess file, I need to manually change any mentions of my http_root directory "/dev/" to "/".

How can I automatically compensate for the changing root directory? I've looked through the apache docs but can't seem to get anything to work.

A couple examples of rewrites:

#Rewrite Index Requests
RewriteRule ^index\.(php|htm|html|asp|aspx|cfm|shtml|shtm)/?$ /dev/ [R=301,NC,L]

#Rewrite contact page requests
RewriteRule ^(.*)contact\.php/?$ /dev/Contact-Page [R,NC,L]
RewriteRule ^Contact-Page/?$ contactpage\.php [NC,L]

Thanks in advance.

share|improve this question
add comment

2 Answers

I'd say just don't dev it with a different root-path than the production system.

It's not that difficult to create a virtual host on your test system - trivial in fact. Just use one.

share|improve this answer
add comment

Personally I would recommend using vhosts and your hosts file so that you don't have to make any changes when moving between environments. Simply decide on a domain for your development such as domainname.dev, and add this to your hosts file. Then add a vhost for that domain that has the /dev/ folder as it's root.

share|improve this answer
add comment

Your Answer


