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

    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: vs
    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^ [NC]
    RewriteRule (.*)$1 [R=301,L,NC]

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


1000 characters left