Hi guys. I’m going to annoy a lot of people with this query, but I’ve got my hands tied as I’ve got to please an SEO company by setting up the redirects in a certain way. htaccess setup is really a bit of a blind spot for me.
Ok here goes (and don’t hate me).
I have a basic html site. They want all the URLS with no extensions and no trailing slash. Fine, that’s excellent, easy to do. Lovely jubbly. Works fine.
Only they came back to me the other day and said “Well actually, we need x page to HAVE a trailing slash at the end” - My head a-splode.
First thing I need to ask is what’s the most sufficient and apache friendly way of achieving this? I’ve been going down the ‘Remove the html and trailing slash EXCEPT this page’ route. However, I’m now going down the way of ‘listen out for a trailing slash on the end and just remove it in the URL’. I’ve also tried the ‘just redirect from mypage/ to mypage’ solution. Doesn’t work either.
Can anyone help? Like I said, I only know the basics in rewrite rules.
My code is:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\\.html -f
#RewriteCond %{REQUEST_URI} !^/page-i-want-to-work-with/
RewriteRule ^(.*)$ $1.html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\\.php -f
RewriteRule ^(.*)$ $1.php
(One of my original ideas is hash’d out)
So yeah, please help. I’ve googled like crazy on this
Tom