【发布时间】:2021-09-22 05:47:57
【问题描述】:
我遇到了很多关于基于 HTTP 查询的重定向以及匹配部分 URL 的问题,但是 不是两者都。
我的目录结构如下:
- http://localhost/common_parent/.htaccess
- http://localhost/common_parent/demo/themes/
- http://localhost/common_parent/themes/?ajax=1
我的重写工作正常,只是它阻止了第二个列表项中的目录:
RewriteCond %{REQUEST_URI} !\.xml$
RewriteRule ^[^/].*/themes(.+) themes$1 [L]
不幸的是,demo/themes/?ajax=1 和 themes/?ajax=1 都是通过ajax HTTP 查询请求的。但是,foo HTTP 查询仅请求 demo/themes/。
- http://localhost/common_parent/demo/themes/?ajax=1&foo=bar
- http://localhost/common_parent/themes/?ajax=1
简而言之,我该如何重写我的rewrite 以仅在存在ajax http 查询时应用同时foo http 查询不在场吗?
【问题讨论】:
标签: apache .htaccess mod-rewrite friendly-url