I want to add rewriterules that works in local environment (localhost) and on my liveserver.
Why?
I don't want to change rules when I test my project locally and upload it to the liveserver.
Adding Rules
Here an example
(ANY-URL)index.php?page=somepage
change to
(ANY-URL)/somepage
So I used a rewritemod generator and pasted this into it:
index.php?page=somepage
The rewriterule I got, looks like this: (of course my .htacces starts with RewriteEngine On)
RewriteRule ^([^/]*)$ /?page=$1 [L]
When I try to get to
(http:) //localhost/myproject/development/index.php?page=login
it sends me to the root directory of my local development envirment. But the URL in the adressline doesn't change.Testing
Of course I tried some other Rules by pasting the whole URL into the generator just to test if the rewrite thing works. Also here the URL doesn't change to short-url but the server cant find stylesheets and javascripts anymore. I got redirected to the index.php
Possible solutions?
- Maybe it has something todo with that "RewriteBase"?
- Do i have to set a basepath?
My .htacces is located here:
//localhost/myproject/development/.htaccess
Later I also want to change paths that look like this:
(ANY-URL)index.php?page=somepage&second=hello&third=world&fourth=cool
Also here a I'm looking for a solution that works on both environments.