SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Feb 2013
    Posts
    18
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Please suggest me how can i able to redirect 301 url in .httaccess file

    I have a old domain name which i like to transfer to another domain name. Please suggest me how can i able to redirect 301 url in .httaccess file.

  2. #2
    Life is not a malfunction gold trophysilver trophybronze trophy
    TechnoBear's Avatar
    Join Date
    Jun 2011
    Location
    Argyll, Scotland
    Posts
    5,325
    Mentioned
    214 Post(s)
    Tagged
    5 Thread(s)
    With something like:

    Code:
    Redirect 301 / http://www.newdomain.com
    I found this tutorial handy. It has a section on Redirection, which explains:
    The first path to the old file must be a local UNIX path. The second path to the new file can be a local UNIX path, but can also be a full URL to link to a page on a different server.
    In this case, you're redirecting the root directory / to a new domain.
    Don't be arrogant. Be kind to a koala that thinks it's a bear.

  3. #3
    SitePoint Zealot Kronomia's Avatar
    Join Date
    Oct 2013
    Posts
    100
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    TechnoBear answer is perfectly accurate.

    You can also issue a permanent redirect from your cPanel if you don't want to alter your .htaccess file by yourself. It is fairly easy though.

  4. #4
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    8,892
    Mentioned
    138 Post(s)
    Tagged
    2 Thread(s)
    If you want to redirect everything to the new domain, not just the root, use

    Code:
    Options +FollowSymlinks -MultiViews
    
    RewriteCond %{HTTP_HOST} !^www\.mynewdomain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.mynewdomain.com/$1 [L,R=301]
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  5. #5
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,149
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ScallioXTX View Post
    If you want to redirect everything to the new domain, not just the root, use
    TechnoBear's redirect directive will do that too.

    EDIT: Though, I think TechnoBear's tutorial got it wrong when it talked about Unix file paths. The argument to redirect is actually a URL path.
    "First make it work. Then make it better."


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •