.htaccess works on local server not on main server

拥有回忆 提交于 2020-01-05 08:56:31

问题


I have the following .htaccess file working on the local MAMP server fine. However when I upload it to the main server it can't find the news page.

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]

The Category and product redirects work fine on the main server however the news doesn't gives a 404 error

other rewrite rules one level higher

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

回答1:


I suspect this is happening due to MultiViews option enabled on your live server which conflicts with `mod_rewrite.

Add this line on top of your .htaccess to disable it:

Options -MultiViews



回答2:


In most cases it will be problem with apache configuration check your apache configuration

Check This for more Information



来源:https://stackoverflow.com/questions/22455539/htaccess-works-on-local-server-not-on-main-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!