htaccess重写除了一个php文件之外的所有文件?

时间:2014-04-03 14:39:39

标签: php .htaccess mod-rewrite

我如何重写所有文件,但只有一个" logout.php" 我试过这个,但它只是给了我一个404:

    <IfModule mod_rewrite.c>
    RewriteEngine on
# You may need to uncomment the following line if rewrite fails to work
# RewriteBase must be setup to base URL of your aMember installation without
# domain name
    RewriteBase /amember4
    RewriteCond %{REQUEST_URI} !^/logout\.php$ [NC]
    RewriteRule ^public public.php [L]
    RewriteRule ^js.php js.php [L]
    RewriteRule !\.(js|ico|gif|jpg|png|css|swf|csv|html)$ index.php
</IfModule>

1 个答案:

答案 0 :(得分:2)

RewriteCond仅适用于下一个RewriteRule。所以你必须重复它,或者在这种情况下,只需在第三个RewriteRule之前将其向下移动:

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteBase /amember4
    RewriteRule ^public public.php [L]
    RewriteRule ^js.php js.php [L]
    RewriteRule ^logout.php logout.php [L]
    RewriteCond %{REQUEST_URI} !^/logout\.php$ [NC]
    RewriteRule !\.(js|ico|gif|jpg|png|css|swf|csv|html)$ index.php
</IfModule>