1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

htaccess redirect

Discussion in 'General Scripting Chat' started by webnise, Jun 12, 2011.

  1. webnise

    webnise Regular Member

    Joined:
    Dec 21, 2009
    Messages:
    296
    Likes Received:
    121
    Location:
    London
    I was developing a site in a subfolder so the url was look like:

    http://www.site.com/website/makeuphair
    http://www.site.com/website/treatment
    etc

    and these URLs have been indexed by search engines.

    Now, I am looking for a general rule for .htaccess that can redirect all the URLs inside the /website folder to relevant pages on the main site. That is,

    http://www.site.com/website/makeuphair
    should redirect to : http://www.site.com/makeuphair

    http://www.site.com/website/treatment
    should redirect to: http://www.site.com/treatment

    Can anybody help me here?
     
  2. linkdropper4

    linkdropper4 Junior Member

    Joined:
    Jun 11, 2010
    Messages:
    131
    Likes Received:
    113
    Occupation:
    Large Ecommerce Company That would Kill Me For Say
    Location:
    USA - Midwest
    Are you wanting like a 301 redirect or a rewrite rule?
     
  3. webnise

    webnise Regular Member

    Joined:
    Dec 21, 2009
    Messages:
    296
    Likes Received:
    121
    Location:
    London
    Anything but I would prefer a generic rewrite rule so that I don't have to write a 301 redirect of every page.
     
  4. webnise

    webnise Regular Member

    Joined:
    Dec 21, 2009
    Messages:
    296
    Likes Received:
    121
    Location:
    London
    Anybody?
     
  5. shughes1

    shughes1 Newbie

    Joined:
    Jun 14, 2011
    Messages:
    14
    Likes Received:
    0
    Would like to know this as well.
     
  6. mrdexter

    mrdexter Junior Member

    Joined:
    May 20, 2011
    Messages:
    184
    Likes Received:
    63
    Redirect 301 /website/treatment http://www.site.com/makeuphair

    The first part should be relative to the .htaccess file, the second part should be the full url of the new page. In the example above the htaccess file would be in the main directory of the main domain (ie public_html or www depending on server.

     
    • Thanks Thanks x 1
  7. drogon

    drogon Elite Member Premium Member

    Joined:
    May 28, 2010
    Messages:
    2,108
    Likes Received:
    1,005
    This is only necessary if you have built links to the original location and want to pass on link juice otherwise just move the content to the new Url location on your website, delete the old links and update your sitemap.

    If you still need to do a redirect anyway then you should have the option to do this in your host account control panel 'Redirect' icon/link/section. This will write the information for you directly into your htaccess file.
     
    • Thanks Thanks x 1
  8. thevil

    thevil Junior Member

    Joined:
    Aug 17, 2010
    Messages:
    190
    Likes Received:
    189
    Code:
    RedirectMatch 301 /website(.*) http://www.site.com/$1
    
     
    • Thanks Thanks x 2
  9. webnise

    webnise Regular Member

    Joined:
    Dec 21, 2009
    Messages:
    296
    Likes Received:
    121
    Location:
    London
    I think this is a good advice regarding moving the content. I will try with htaccess first and if didn't work then I will remove the old links.

    Thanks everyone :)