我需要发出重定向,使用。htaccess,与一个片段(也称为锚)的URL,但它自动转义#
目前,我希望有一个硬codeD片段,而是为他人着想,如果你知道如何利用它的URL也将是一件好事。
理想我应该能够使用QSA以及
例如:
www.exameple/test?foo=bar
应成为
1)www.example/?foo=bar#MYVALUE
或从URL以片段:
2)www.example/?foo=bar#test
我的(非工作)code是这样的:
重写规则/测试www.example/#MYVALE [R,QSA]解决方案
我想我已经想通弄明白了......
的RewriteCond%{} HTTPS关闭 的RewriteCond%{REQUEST_URI} /测试 重写规则^测试/?(.*)$ $ 1 [C] 重写规则^ $ HTTP(*)://%{HTTP_HOST} / $ 1%{QUERY_STRING} #MYVALUE [NE,L,R] 的RewriteCond%{} HTTPS上 的RewriteCond%{REQUEST_URI} /测试 重写规则^测试/?(.*)$ $ 1 [C] 重写规则^ $ HTTPS(*)://%{HTTP_HOST} / $ 1%{QUERY_STRING} #MYVALUE [NE,L,R]
这是一个有点差不必做一次HTTP和再次HTTPS - 我去看看能不能找到办法解决
。I need to issue a redirect, using .htaccess, to a URL with a fragment (also known as an anchor), but it's automatically escaping the #.
At the moment I want a hard-coded fragment, but for the sake of others if you know how to take it from the URL too that would be good.
Ideally I should be able to use QSA as well.
For example:
www.exameple/test?foo=barshould become
1) www.example/?foo=bar#MYVALUEor taking the fragment from the url:
2) www.example/?foo=bar#testMy (non-working) code looks like this:
RewriteRule /test www.example/#MYVALE [R,QSA]解决方案
I think I've got it figured out...
RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} /test RewriteRule ^test/?(.*)$ $1 [C] RewriteRule ^(.*)$ %{HTTP_HOST}/$1?%{QUERY_STRING}#MYVALUE [NE,L,R] RewriteCond %{HTTPS} on RewriteCond %{REQUEST_URI} /test RewriteRule ^test/?(.*)$ $1 [C] RewriteRule ^(.*)$ %{HTTP_HOST}/$1?%{QUERY_STRING}#MYVALUE [NE,L,R]It's a bit poor having to do it once for HTTP and again for HTTPS - I'll see if I can find a way around that.
更多推荐
的.htaccess与片段重定向
发布评论