新建.htaccess文件,输入下列内容(需要开启mod_rewrite):
1)将不带www的域名转向到带www的域名下
- options +followsymlinks
- rewriteengine on
- rewritecond %{http_host} ^embeta.com [nc]
- rewriterule ^(.*)$ $1 [l,r=301]
2)重定向到新域名
- options +followsymlinks
- rewriteengine on
- rewriterule ^(.*)$ $1 [l,r=301]
3)使用正则进行301转向,实现伪静态
- options +followsymlinks
- rewriteengine on
- rewriterule ^news-(.+).html1
将news.php?id=123这样的地址转向到news-123.html
4、apache下vhosts.conf中配置301重定向,为实现url规范化,通常将不带www的域名转向到带www域名,vhosts.conf中配置为:
-
- servername documentroot /home/embeta
-
-
- servername embeta.com
- redirectmatch permanent ^/(.*) $1
-
|