简体   繁体   English

.htaccess 301 重定向问题

[英].htaccess 301 redirect issue

I need 301 redirect from example.com to www.example.com.我需要从 example.com 到 www.example.com 的 301 重定向。 This is working solution, but when I paste it in whole .htaccess site go down.这是可行的解决方案,但是当我将其粘贴到整个 .htaccess 站点 go 中时。

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

Rest .htaccess file Rest .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

Whats the AllowOverride value of the folder where you have your .htaccess?您拥有 .htaccess 的文件夹的AllowOverride值是多少? Your DocumentRoot (or VirtualHost ) specification needs to be set to at least AllowOverride Options in order to allow php_flag within .htaccess files.您的DocumentRoot (或VirtualHost )规范需要至少设置为AllowOverride Options以允许php_flag文件中的 php_flag。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM