Forum Moderators: phranque
Say we have a site located at http://www.example.com/subfolder/.
our SEO guys are telling us to move everything from /subfolder/ to the root, and create a 301 redirect rule, so that any request containing /subfolder/ gets redirected to a similar URL, just *without* /subfolder/.
All parameters, etc. must be preserved. (Important!)
Examples:
So, the general idea is to replace all instances of "example.com/subfolder/" with "example.com/", without touching anything else, and 301-redirect to the resulting string.
How can this be done?
Oh, and we already have a "non-www to www" redirect rule in our htaccess, so where should the new rule be placed? (before or after?)
Thanks in advance!
When trying to establish rule order, a good rule of thumb is to put all external redirects first, ordered from most-specific (fewest URLs affected) to least specific ("catch-alls" such as domain canonicalization), followed by all internal rewrites, again ordered from most- to least-specific.
Please review the documentation cited in our Apache Forum Charter, and then post you best-effort code as a basis for discussion.
Thanks,
Jim
I'm very much a newbie with htaccess but I know there's a catch or two about parameters... and the case in your thread sounds a bit different. Glad to see you've received a solution though.
if anyone could help with my specific situation above it would be highly appreciated... thanks again!
Jim
# Test-subfolder to root
RewriteRule ^subfolder/(.*) /$1 [R=301]
I don't suppose there anything else to watch for? any special caveats? (Yes, I know this is a simple matter... but I don't really trust myself yet and it's vital that our search rankings won't suffer).
Thanks for the guidance!
# Externally redirect all requests for test-subfolder resources to corresponding resources in root
RewriteRule ^subfolder/(.*)$ http://www.example.com/$1 [R=301,L]