开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜