开发者

htaccess rewrite with double rules (with version)

开发者 https://www.devze.com 2023-04-11 13:04 出处:网络
I hope a htaccess script voodoo can help me h开发者_高级运维ere! I\'m trying to get a htaccess script working using two rules.

I hope a htaccess script voodoo can help me h开发者_高级运维ere!

I'm trying to get a htaccess script working using two rules.

I was using a first rule to use folders for different versions, which was great:

RewriteEngine On
RewriteRule .* - [E=VERSION:020]
RewriteRule ^versions/(.*)$ versions/$1 [L]
RewriteRule ^(.*)$ versions/%{ENV:VERSION}/$1 [L]

Then I had a structure that take:

http://domain.com/
http://domain.com/th?=1
http://domain.com/myfolder/
http://domain.com/myfile.html

and send the user to the version that set in the htaccess:

http://domain.com/versions/020/
http://domain.com/versions/020/th?=1
http://domain.com/versions/020/myfolder/
http://domain.com/versions/020/myfile.html

All working.

But I'd like to add a second rule but I can't get it working with the first rule

I'd like to get these URL:

http://domain.com/th/1
http://domain.com/th/12

and send the user to:

http://domain.com/?th=1
http://domain.com/?th=12

and by extension of the first rule:

http://domain.com/versions/020/?th=1
http://domain.com/versions/020/?th=12

I tried to add:

RewriteRule ^th/([0-9]+)/$ http://domain.com/versions/%{ENV:VERSION}/?th=$1

But that works only without the first rule (I also can't make it working without the domain name strangely).

How can make this 2 rules working together? Any hint on that?

Cheers.

Romu

0

精彩评论

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