htaccess rewriterule leading slash
- by Tiddo
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?