新建.htaccess文件,输入下列内容(需要开启mod_rewrite):
1)将不带WWW的域名转向到带WWW的域名下
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^test.com [NC]
RewriteRule ^(.*)$ http://www.test.com/$1 [L,R=301]
2)重定向到新域名
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ http://www.test.com/$1 [L,R=301]
3)使用正则进行301重定向,实现伪静态
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^news-(.+)\.html$ news.php?id=$1
将news.php?id=123这样的地址转向到news-123.html
Apache下vhosts.conf中配置301重定向
为实现URL规范化,SEO通常将不带WWW的域名转向到带WWW域名,vhosts.conf中配置为:
<VirtualHost *:80>
ServerName www.test.com
DocumentRoot /home/test
</VirtualHost>
<VirtualHost *:80>
ServerName test.com
RedirectMatch permanent ^/(.*) http://www.test.com/$1
</VirtualHost>
Apache下除了以上几种方法,还有其他配置方法和可选参数,建议阅读Apache文档。
Hello! kcebkkb interesting kcebkkb site!
rollos
I must bring the choice pertaining to thanking somebody for its skilled professional referrals I have got much liked studying your web page. We’re eager for any graduation towards get secondary education studies with all the main footwork wouldn’t appear to have been conduct without ever showing up onto your site. House are generally for any advantage of many others, I am happy that will as to what We certainly have noticed from this point.