开发者

Can these two rewrite rules be written in a better way/merged?

开发者 https://www.devze.com 2023-03-16 17:50 出处:网络
I have the following rewrite rules: RewriteRule ^(.*)/(stylesheets|javascript)/[0-9]+/(.*)$ /$1/$2/$3 [L]

I have the following rewrite rules:

RewriteRule ^(.*)/(stylesheets|javascript)/[0-9]+/(.*)$ /$1/$2/$3 [L]
RewriteRule ^(stylesheets|javascript)/[0-9]+/(.*)$ /$1/$2 [L]

it lets me do /foo/stylesheets/123456/bar.css which maps to /foo/stylesheets/bar.css and /stylesheets/123456/bar.css which maps to /stylesheets/bar.css

However I was just wondering if they could be merged somehow?

I tried changing it to just:

RewriteRule (stylesheets|javascript)/[0-9]+/(.*)$ $1/$2 [L]开发者_运维知识库

but that didn't work for anything with /foo/stylesheets/

Thanksl


Try this one:

RewriteRule ^(.+/)?(stylesheets|javascript)/[0-9]+/(.*)$ /$1$2/$3 [L]

I'm just unsure how much performance it will give you (maybe even opposite).

0

精彩评论

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

关注公众号