Adding 301 redirects using htaccess

来源:互联网 发布:传奇霸业龙脉各阶数据 编辑:程序博客网 时间:2024/05/20 12:51

It’s easy adding 301 redirects to your website using Apache’s htaccess. A 301 redirect is the most efficient and Search Engine Friendly method for web page redirection. It’s not difficult to implement and will preserve your search engine rankings as well.

So, basically how this works is when someone tries to access yourwebsite without the (www), it will redirect the URL to your websitewith the www.

To implement this for your website follow these instructions:

  1. Open up notepad or any other text editor and copy and paste the commands below.
  2. Change (yourdomain) to your domain name.
  3. Save the file with this name: (.htaccess). There is no file name.
  4. Upload it to the root directory of your website.

 

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain/.com$ [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]

原创粉丝点击