I decided to use mod_rewrite
to make my URLs look better. I created very simple rules:
RewriteEngine on
RewriteBase /
RewriteRule ^(profile|contact|help|events|account|logout)/?$ index.php?p=$1 [NC]
RewriteRule ^home/?$ index.php [NC]
RewriteRule ^PlaceOrder/([0-9]+)/?$ index.php?p=mos&gc=$1 [NC]
It almost works well but it doesn't. So for example, [NC]
is supposed to make it case-insensitive. However, for some reason, when I type for example localhost/Help
in the browser, for some strange reason, it redirects to home page.
Another issue is with the last rule. If I type in localhost/PlaceOrder/1
it works as expected and opens index?p=mos&gc=1
. But after that if I click on, for example, Account button, the browser uses this URL: localhost/PlaceOrder/account
. Which is wrong. It should only use localhost/account
. Why is it adding that sub-directory in there? It is only happening after the last rule is used. Prior to using the last rule, all links work well.