2

我遇到了 .htaccess 的问题……我所有的页面都被重定向到一页

这是我的 .htaccess

已编辑

 <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

4

1 回答 1

1

您遇到此问题是因为您没有使用L(Last) 标志。将您的代码更改为:

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]
于 2013-05-23T04:18:12.940 回答