2011-07-20 203 views
0

我需要301從example.com重定向到www.example.com。這是工作的解決方案,但是當我在整個.htaccess網站上粘貼它時,就會關閉。.htaccess 301重定向問題

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

休息.htaccess文件

php_flag magic_quotes_gpc off 
php_flag magic_quotes_runtime off 
php_flag register_globals off 

RewriteEngine On 

RewriteRule ^.htaccess$ - [F] 
RewriteCond %{REQUEST_FILENAME} -f 
RewriteRule ^(.*)$ $1 [L] 
Options -Indexes 
AddDefaultCharset windows-1251 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(service|news|search|project)/?$ index.php?menu=$1 
RewriteRule ^error/([0-9]+)/?$ index.php?menu=error&loadinfo=$1 
RewriteRule ^page/([0-9]+)/?$ index.php?menu=page&loadinfo=$1 
RewriteRule ^news/([0-9]+)/?$ index.php?menu=news&loadinfo=$1 
RewriteRule ^news/page-([0-9]+)/?$ index.php?menu=news&page=$1 
RewriteRule ^service/([0-9]+)/?$ index.php?menu=service&category=$1 
RewriteRule ^service/([0-9]+)/([0-9]+)/?$ index.php?menu=service&category=$1&loadinfo=$2 
RewriteRule ^project/([0-9]+)/?$ index.php?menu=project&loadinfo=$1 

回答

1

請告訴我,你有你的.htaccess文件夾的AllowOverride價值?您的DocumentRoot(或VirtualHost)規範需要設置爲至少AllowOverride Options,以便在.htaccess文件中允許php_flag

RewriteCond %{HTTP_HOST} ^example.com 
RewriteRule (.*) http://www.example.com/$1 [R=301,L]