Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using htaccess to rewrite my urls so that I can have nice clean urls. However, the same htaccess file does different things on my local server and my remote server:

On my local server the url to the website is like http://localhost/example/ and on my remote server the url is http://example.com/.

For my local server I can use the following htaccess redirect rule:

RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]

However, when I use this on my remote server I get an internal server error. Instead I have to use this: (note the leading slash)

RewriteRule ^(.*)$ /index.php?page=$1 [L,QSA]

Unfortunately this doesn't work on my local server: this rewrite rule requests http://localhost/index.php instead of http://localhost/example/index.php on my local server.

How can I make this work on both my remote and local server?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

The best solution would be to change your DocumentRoot on your development server so that the URIs (and hence all the rewrites) are the same as the production server.

If you have multiple sites on your development server that you are currently keeping in separate folders, you can use separate subdomains for them instead.

share|improve this answer
    
Thanks, this worked! –  Tiddo Apr 3 '12 at 14:07

That directive should work just fine in any directory context.

Please provide the error from its log when it responds with a 500 Internal Server Error, as well as other relevant configuration from that system.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.