1

Let's say I have the following urls:

site/DB/guest/picture/25-298.jpg?v=140913231208
site/DB/guest/picture/25.jpg?v=140913231208
site/DB/user/cover/27-40.jpg?v=160913051508
site/DB/user/cover/27.jpg?v=160913051508

site/JS/main.js?v=160913132025
site/JS/utils/admin.js?v=1602144214027
site/CSS/main.css?v=160913132038

I want to be able to load them by accessing urls below:

guest/picture/140913231208/25-298.jpg
guest/picture/140913231208/25.jpg
user/cover/160913051508/27-40.jpg
user/cover/160913051508/27.jpg

js/160913132025/main.js
js/utils/1602144214027/admin.js
css/160913132038/main.css

I've tried to Rewrite some Rules. But I always get the Not Found Error.

For example:

RewriteRule ^js/(.*)/(.*).(.*)$ site/JS/$2.$3\?v=$1 [L]
4

1 回答 1

3

Try:

RewriteRule ^guest/picture/([0-9]+)/(.*)$ /site/DB/guest/picture/$2?v=$1 [L,QSA]
RewriteRule ^user/cover/([0-9]+)/(.*)$ /site/DB/user/cover/$2?v=$1 [L,QSA]
RewriteRule ^js/([0-9]+)/(.*)\.js$ /site/JS/$2.js?v=$1 [L,QSA]
RewriteRule ^js/utils/([0-9]+)/(.*)\.js$ /site/JS/utils/$2.js?v=$1 [L,QSA]
RewriteRule ^css/([0-9]+)/(.*)\.css$ /site/CSS/$2.css?v=$1 [L,QSA]

RewriteRule ^(js|css)(/utils)?/([0-9]+)/(.*)$ /$1$2/$4?v=$3 [L,QSA]
于 2013-09-16T13:20:38.657 回答