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

后端 未结 4 1468
臣服心动
臣服心动 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:08

    try

    RewriteRule ^/css/css\.css css/css.php [L]
    RewriteRule ^/js/js\.js js/js.php [L]
    RewriteRule ! /^img/.* index.php
    

    ie. if you ^-anchor the pattern to the beginning of the string, start it with a /. patterns are matched against URL-paths, which start with /.

    EDIT

    above is valid for server config, virtual host, and directory context only. if the context is .htaccess, the per-directory prefix including the first slash is stripped before the rule is matched (and prepended afterwards), so no need for ^/ here.

提交回复
热议问题