重写规则的波浪 [英] RewriteRule for tilde
问题描述
我试图做波浪的URL重写如下:
I am trying to do the following rewrite of tilde URLs:
RewriteRule ^/?~folder/(.*) http://whatever.com/$1 [R=302,L]
我想与 whatever.com/~folder/something
的任何链接,成为 whatever.com/something
。
I want any links with whatever.com/~folder/something
to become whatever.com/something
.
看来,上述重写规则的作品,如果我的情况排除了波浪线(也试图逃避它, \〜
),但随着波浪不执行重写
It seems that the above rewrite rule works if my situation excluded the tilde (also tried escaping it, \~
), but with the tilde it does not perform the rewrite.
是否有更广泛的配置设置,我需要调整,以便在我的处境重写?我通常理解〜文件夹
指的是用户的主目录,但我不知道怎么说进场,也可以在我的情况进行调整。
Is there a broader configuration setting I need to adjust to enable rewriting in my situation? I understand normally ~folder
refers to a user's home directory, but I don't know how that comes into play or can be adjusted in my situation.
推荐答案
我能够修复任何命中的 HTTP://domain.ext/~blog/file.html ,并在此根目录的.htaccess规则(的public_html):
I was able to fix any hits to http://domain.ext/~blog/file.html with this .htaccess rule at webroot (public_html):
RewriteRule ^~blog/(.*)$ /site/legacy/users/blog/$1 [R=301,L]
来源: http://webmaster.iu.edu/工具和导游/维护/重定向-htaccess.phtml
这篇关于重写规则的波浪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!