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
to this (including a trailing backslash)
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.
RewriteRule ^([^/\\.]+)/$ /index.php?page=$1 [L]
So in short the two problems I have with this are:
1. It doesn't actually redirect the URL, it just allows both version to work.
2. If I tried to use the new url without the trailing backslash
it will just bring up the 404 page. It should redirect to the page with a trailing slash.
Any help will be much appreciated
What've you attempted was not a bad effort but I'd REALLY advise not mimicing directories (trailing /'s) as that introduces an incorrect directory level in the path for your relative links.
If you're assured that your "animals" will always be lowercase characters, I'd use
RewriteRule ^([a-z]+)$ index.php?page=$1 [L]
This topic is now closed. New replies are no longer allowed.