apache 301重定向配置的例子
apache 301重定向配置的例子
新建.htaccess文件,输入下列内容(需要开启mod_rewrite):
1)将不带WWW的域名转向到带WWW的域名下
- Options +FollowSymLinks
- RewriteEngine on
- RewriteCond %{HTTP_HOST} ^163.com [NC]
- RewriteRule ^(.*)$ http://www.163.com/$1 [L,R=301]
- Options +FollowSymLinks
- RewriteEngine on
- RewriteRule ^(.*)$ http://www.jbxue.com/$1 [L,R=301]
- Options +FollowSymLinks
- RewriteEngine on
- RewriteRule ^news-(.+)\.html$ news.php?id=$1
Apache下vhosts.conf中配置301重定向
为实现URL规范化,SEO通常将不带WWW的域名转向到带WWW域名,vhosts.conf中配置为:
- <VirtualHost *:80>
- ServerName www.jbxue.com
- DocumentRoot /home/fari001Com
- </VirtualHost>
- <VirtualHost *:80>
- ServerName fari001.com
- RedirectMatch permanent ^/(.*) http://www.jbxue.com/$1
- </VirtualHost>
评论暂时关闭