Help 301 redirecting subdirectory to root

3 replies
I just bought a website, and there are some backlinks floating around to one of my subdirectories that seem pretty popular..I want to redirect (.htaccess) to my homepage to retain some of the PR

Anything in www.domain.com/directory1/subdir1/

I want directed to www.domain.com

I tried: redirect 301 /directory1/subdir1/ http://www.domain.com

but that doesn't work...I believe that just removes the folders from the URL.
#301 #redirecting #root #subdirectory
  • Profile picture of the author cgimaster
    Code:
    RedirectMatch 301 ^/directory1/subdir1/(.*)$ http://www.domain.com
    Should work

    Note that (.*) will match anything else that comes after subdir1
    {{ DiscussionBoard.errors[7258958].message }}
  • Profile picture of the author Danny Woolard
    Works! thank you.
    {{ DiscussionBoard.errors[7259136].message }}
  • Profile picture of the author cgimaster
    Glad you managed it to work if you have any other questions feel free to PM or post here.
    {{ DiscussionBoard.errors[7259553].message }}

Trending Topics