我有以下.htaccess文件在本地MAMP服务器上正常工作。但是,当我将其上传到主服务器时,它无法找到新闻页面。
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \s/+news\.php\?news_id=([^\s&]+) [NC]
RewriteRule ^ /news/%1? [R=301,L]
RewriteCond %{THE_REQUEST} \s/+Category\.php\?pageNum_RS_Search=([^\s&]+)&totalRows_RS_Search=([^\s&]+)&Category=([^\s&]+) [NC]
RewriteRule ^ /Compare/%1/%2/%3? [R=301,L]
RewriteCond %{THE_REQUEST} \s/+Category\.php\?Category=([^\s&]+) [NC]
RewriteRule ^ /Compare/%1? [R=301,L]
RewriteCond %{THE_REQUEST} \s/+product\.php\?id=([^\s&]+) [NC]
RewriteRule ^ %1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)?$ product.php?id=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^Compare/([^/]+)/?$ Category.php?Category=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^Compare/([^/]+)/([^/]+)/([^/]+)/?$ Category.php?pageNum_RS_Search=$1&totalRows_RS_Search=$2&Category=$3 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^news/([^/]+)/?$ news.php?news_id=$1 [L,QSA]
类别和产品重定向在主服务器上正常工作,但新闻不会出现404错误
其他重写规则高一级
rewriteengine on
rewritecond %{HTTP_HOST} ^www.mysite1.co.uk$ [OR]
rewritecond %{HTTP_HOST} ^mysite1.co.uk$
rewriterule ^(.*)$ "http\:\/\/mysite\.co\.uk\/$1" [R=301,L] #5311a623b538f
rewritecond %{HTTP_HOST} ^www.mysite.co.uk$ [OR]
rewritecond %{HTTP_HOST} ^mysite.co.uk$
rewriterule ^Pianoshop\/detailed_page\.php(.*)$ "http\:\/\/mysite\.co\.uk\/product\.php$1" [R=301,L] #5310700a7e477
rewritecond %{HTTP_HOST} ^www.mysite.co.uk$ [OR]
rewritecond %{HTTP_HOST} ^mysite.co.uk$
rewriterule ^Pianoshop\/index_blog\.php(.*)$ "http\:\/\/mysite\.co\.uk\/news\.php$1" [R=301,L] #531
答案 0 :(得分:0)
在大多数情况下,apache配置检查你的apache配置会出现问题
答案 1 :(得分:0)
我怀疑这是因为您的实时服务器上启用了MultiViews
选项而与`mod_rewrite冲突。
在.htaccess上添加此行以禁用它:
Options -MultiViews