I have created a simple dynamic website with php and I am having trouble making my URL structure search engine friendly.
What I am trying to do is redirect links like this
www.example.com/index.php?page=animals
to this (including a trailing backslash)
www.example.com/animals/
I have spent ages searching for a solution and found the below is the only one that actually lets the new URL work but I can’t redirect it.
It seems to be backwards to every other solution I have seen, when I add R=301 into the rule it redirects the nice url to the long version.
RewriteEngine On
RewriteRule ^([^/\\.]+)/$ /index.php?page=$1 [L]
So in short the two problems I have with this are:
- It doesn’t actually redirect the URL, it just allows both version to work.
- If I tried to use the new url without the trailing backslash
www.example.com/animals
it will just bring up the 404 page. It should redirect to the page with a trailing slash.
Any help will be much appreciated
Many thanks