Apache Mod Rewrite: RewriteRule with L argument. What's wrong?

后端 未结 4 1522
臣服心动
臣服心动 2021-01-22 22:27

I\'m developing a php application and I have a little issue with Apache and Mod Rewrite. Anyone knows what\'s wrong here?:

RewriteEngine on
RewriteBase /mysite/
         


        
4条回答
  •  野性不改
    2021-01-22 23:06

    Centauro12, the problem is, that the [L] flag in fact stops propagation through the following rules, but then (if you are in an .htaccess file) the URL mapping starts over again. That means, all your rules will then be processed a second time. See the Apache Rewrite Guide for the details.

    Therefore you need to explicitly disable rewriting for your rewritten php scripts:

    RewriteRule ^css/css.php - [L]
    RewriteRule ^js/js.php - [L]
    

    or more compact (although perhaps not what you want):

    # don't rewrite anything that really exists
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .* - [L]
    

提交回复
热议问题