我遇到问题.htaccess ...我的所有网页都会重定向到一个页面
这是我的.htaccess
EDITED
<FilesMatch "\.(html|css|js|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=29030400, proxy-revalidate"
</FilesMatch>
<ifmodule mod_deflate.c>
<filesmatch \.(css|html|js|php|xml)$>
setoutputfilter deflate
</filesmatch>
</ifmodule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^about-trust(.*)$ /trust_detail.php?id=no$1 [L]
RewriteRule ^college(.*)$ /gallery.php?type=college$1 [L]
RewriteRule ^trust(.*)$ /gallery.php?type=trust$1 [L]
RewriteRule ^academy(.*)$ /gallery.php?type=academy$1 [L]
RewriteRule ^press(.*)$ /gallery.php?type=press$1 [L]
</IfModule>
我的所有网页都会重定向到gallery.php,就像我尝试打开trust_detail.php一样,它也会重定向到gallery.php
答案 0 :(得分:1)
您遇到此问题是因为您没有使用L
(最后)标记。将您的代码更改为:
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^ - [L]
RewriteRule ^about-trust(.*)$ /trust_detail.php?id=no$1 [L,QSA]
RewriteRule ^college(.*)$ /gallery.php?type=college$1 [L,QSA]
RewriteRule ^trust(.*)$ /gallery.php?type=trust$1 [L,QSA]
RewriteRule ^academy(.*)$ /gallery.php?type=academy$1 [L,QSA]
RewriteRule ^press(.*)$ /gallery.php?type=press$1 [L,QSA]