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?
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.
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.