Apache mod_rewrite only if request does not start with '/THEMES/'

前端 未结 4 888
借酒劲吻你
借酒劲吻你 2021-01-08 00:11

I\'m writing a CMS in PHP, and now I\'m working at the themes feature. I have a .htaccess file:

RewriteEngine ON
RewriteRule ^([a-zA-Z][a-zA-Z0-9]*)$ index.p         


        
4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-08 00:28

    Do something like:

    RewriteRule ^THEMES - [L]
    

    That means: if the request starts with THEMES, just serve it.

    Another possible solution is:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d 
    

    That means: do not rewrite if the request resolves to an existing file (first line) or directory (second line).

    Maybe you should read the documentations, is really well written.

提交回复
热议问题