开发者

Mod Rewrite Regex - Match a url containting A but not B

开发者 https://www.devze.com 2023-03-17 02:34 出处:网络
I\'m trying to send page requested through a front controller. I need to match the following urls domain.com/admin/

I'm trying to send page requested through a front controller.

I need to match the following urls

domain.com/admin/
domain.com/admin/somepage

but I also have some assets in the /admin subfolder that I DONT want to match

domain.com开发者_Python百科/assets
domain.com/assets/mything.css
domain.com/assets/mything.css
domain.com/xml/myxml.xml

I have written the following rule (inside .htaccess in the root of the site and that works for all 5 example URLs. How do I get it to match the top two ONLY?)

RewriteBase / 
# index.php is the front controller
RewriteRule ^(admin) admin/index.php [L,QSA] 

There are two ways I can see of doing this (I'd like to know how to do it using the folder 'assets' and 'xml' as an exclusion AND by setting extensions)


I'd use a negative RewriteCond before the final routing rule along these lines:

RewriteCond %{REQUEST_URI} !assets 
0

精彩评论

暂无评论...
验证码 换一张
取 消