Excluding files from htaccess rewrite rules

前端 未结 2 1883
一生所求
一生所求 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

提交回复
热议问题