Help 301 redirecting subdirectory to root

by 3 replies
4
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.
#programming #301 #redirecting #root #subdirectory
  • Code:
    RedirectMatch 301 ^/directory1/subdir1/(.*)$ http://www.domain.com
    Should work

    Note that (.*) will match anything else that comes after subdir1
    • [ 1 ] Thanks
  • Works! thank you.
  • Glad you managed it to work if you have any other questions feel free to PM or post here.

Next Topics on Trending Feed