Forum Moderators: phranque
Firstly let me apologize for such a noobish question, but I’m at wits end here. I have a journal type site where the majority of my files are held in one folder. So not surprisingly www.site.com/folder/ for whatever reason gets a bunch of hits and some PR as well. I want to redirect any landings that fall on www.site.com/folder to www.site.com/ .
However I want to make sure I’m doing it in as SEO friendly way as possible, i.e users still have to be able to access files (images/pages) in that folder but there is no need for them to see www.site.com/folder/ itself, in my estimation as all navigation is done form the main page.
I’ve tried various rewrites and redirects but none of them seem to do what I’m after, I’ve tried searching for the answer and I get close, but the others who have gotten guidance always seem to be asking for something a little different, than my seemingly simple problem. I tried the apache documentation as well, but it reads like greek to me.
Any help would be greatly appreciated
RewriteEngine on
RewriteCond %{REQUEST_URI}!^/folder/images/
RewriteCond %{REQUEST_URI}!^/folder/do_not_redir_this/
RewriteCond %{REQUEST_URI}!^/folder/another/path/to/not/redirect
RewriteCond %{REQUEST_URI} ^/folder/do/not/redirect/this/file.html$
RewriteRule ^/folder/(.*) /$1 [L,R=301]
Untested, but ought to do more or less what you need (assuming I understand the question).
Thanks much for the reply. So I understand this, if you could please explain which part of that tells any direct requests for site.com/folder/ to just go to www.site.com
I don’t really see that, although that might be very indicative of the whole problem, I just don’t get rewrites very well.
Thanks for your response.
Note that you'll need to place a space between %{REQUEST_URL} and the '!' character in all the RewriteCond lines, or you'll get an Internal Server Error (error 500)