Hi I have a website, which is operating under a folder . So the front page url is domain.com/sub-folder I have lot of backlinks but i do want to remove the "sub-folder" and put everything back in parent directory However I want my backlinks to still work. If someone have a backlink domain.com/sub-folder/page.html it should redirect it to domain.com/page.html since after I put everything in parent, the subfolder will not exist Can this be done ? Please help
Thanks ... i dont know how to do that. So not sure how i could have figured that out. But will remember for next time.
put an .htaccess file in the documentroot which contains: RewriteEngine On RedirectPermanent /sub-folder/page.html http://yourdomain.com/ Code (markup):
Thanks mergemedia But i am not sure if this will take care of all pages. I have hundreds of URLs . So How will we modify this to make it work for all pages /sub-folder/page1.htm - page1.htm /sub-folder/page2.htm goes to page2.htme
Bring on the power of regular expressions ! RewriteRule /sub-folder/(.*) /$1 [R=301,NC,L] Code (markup): The $1 in the second part of the rewrite rule matches anything in the parentheses () in the first part of the rewrite rule. So if you request /sub-folder/foo.html Code (markup): you will be told that the page has moved permanently to /foo.html Code (markup): If you request /sub-folder/anotherfolder/yetanotherfolder/foo.html Code (markup): you will be told that the page has moved permanently to /anotherfolder/yetanotherfolder/foo.html Code (markup):