htaccess 用双重规则重写(带版本)
我希望 htaccess 脚本 voodoo 可以帮助我!
我正在尝试使用两个规则让 htaccess 脚本工作。
我使用第一条规则来使用不同版本的文件夹,这很棒:
RewriteEngine On
RewriteRule .* - [E=VERSION:020]
RewriteRule ^versions/(.*)$ versions/$1 [L]
RewriteRule ^(.*)$ versions/%{ENV:VERSION}/$1 [L]
然后我有一个结构,它采用:
http://domain.com/
http://domain.com/th?=1
http://domain.com/myfolder/
http://domain.com/myfile.html
并将用户发送到 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
所有工作。
但我想添加第二条规则,但我无法让它与第一条规则一起使用
,我想获取这些 URL:
http://domain.com/th/1
http://domain.com/th/12
并将用户发送到:
http://domain.com/?th=1
http://domain.com/?th=12
并通过第一条规则的扩展:
http://domain.com/versions/020/?th=1
http://domain.com/versions/020/?th=12
我尝试添加:
RewriteRule ^th/([0-9]+)/$ http://domain.com/versions/%{ENV:VERSION}/?th=$1
但这仅在没有第一条规则的情况下才有效(奇怪的是,如果没有域名,我也无法使其工作)。
如何使这两条规则协同工作?有什么提示吗?
干杯。
罗姆
I hope a htaccess script voodoo can help me here!
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论