Apache服务器的301重定向
03月 5, 2008
01重定向:abc.com到www.abc.com
- RewriteEngine On
- RewriteBase /
- RewriteCond %{HTTP_HOST} !^www.abc.com$ [NC]
- RewriteRule ^(.*)$ http://www.abc.com/$1 [L,R=301]
或者
- Options +FollowSymLinks
- RewriteEngine on
- RewriteCond %{HTTP_HOST} ^abc\.com
- RewriteRule ^(.*)$ http://www.abc.com/$1 [R=permanent,L]
或者
- Options +FollowSymLinks
- RewriteEngine On
- RewriteCond %{HTTP_HOST} ^abc\.com$ [NC]
- RewriteRule ^(.*)$ http://www.abc.com/$1 [R=301,L]
301重定向:www.abc.com 到 abc.com
- RewriteEngine On
- RewriteBase /
- RewriteCond %{HTTP_HOST} !^abc.com$ [NC]
- RewriteRule ^(.*)$ http://abc.com/$1 [L,R=301]
301重定向:单个页面的301转向
- Redirect 301 /a.html http://www.xyz.com/b.html
Apache配置中实现301转向
- <VirtualHost xxx.xxx.xxx.xxx>
- ServerName domain.com
- DocumentRoot /home/domain/www
- </VirtualHost>
- <VirtualHost xxx.xxx.xxx.xxx>
- ServerName www.domain.com
- Redirect 301 / http://domain.com/
- </VirtualHost>
发表在



