htaccess Redirects

How to create a 301 Redirect using htaccess from an old URL to the new URL

 

  • In order to redirect an old URL to the new URL you can use a 301 redirect in htaccess. Here is an example:
    redirect 301 /oldfile http://www.yourdomainname/newfile

    Note:
    You will need to replace "oldfile" , "yourdomainname" , and "newfile" with the correct values.
  • To redirect all requests to domainname to www.domainname:
    # Rule for duplicate content removal: www.domain.com vs domain.com
    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^domain.com [NC]
    RewriteRule (.*) http://www.domain.com/$1 [R=301,L,NC]

    Note:
    This .htaccess redirect only works on Linux servers with Apache Mod-Rewrite enabled. (All of Power Shift's Linux Servers has this enabled)

 

Request a Free Quote!
1000 characters left