Excluding files from htaccess rewrite rules

前端 未结 2 1859
一生所求
一生所求 2021-01-06 13:42

I have an htaccess rewrite setup in my PHP application to route files via the bootstrapper file. In essence, the goal is to take a URL such as www.domain.com/view/key/value

相关标签:
2条回答
  • 2021-01-06 14:05

    You should move your new rule atop the RewriteCond block:

    RewriteRule ^/?ajaxDispatcher.php$ - [L]
    

    Otherwise the RewriteConditions don't cover the extensions RewriteRule anymore, for which I assume they are intended.

    Another alternative is turning it into another RewriteCond of course:

    RewriteCond %{SCRIPT_NAME}  !ajaxDispatcher
    

    Or injecting it as assertion into the final RewriteRule (?!ajaxDispatcher.php).

    The ordering thing is best explained on Serverfault: https://serverfault.com/questions/214512/everything-you-ever-wanted-to-know-about-mod-rewrite-rules-but-were-afraid-to-as

    0 讨论(0)
  • 2021-01-06 14:08

    If you remove the ajaxDispatcher.php line from the code you show, it should work - because of the !-f and !-d rules, requests to files that actually exist will be excluded from the rewrite ruke.

    0 讨论(0)
提交回复
热议问题