波形符的重写规则

发布于 2024-12-01 04:43:33 字数 395 浏览 1 评论 0原文

我正在尝试对波形符 URL 进行以下重写:

RewriteRule ^/?~folder/(.*) http://whatever.com/$1 [R=302,L]

我希望任何带有 whatever.com/~folder/something 的链接都变为 whatever.com/something

如果我的情况排除了波形符(也尝试转义它, \~ ),则上述重写规则似乎有效,但使用波形符时,它不会执行重写。

我是否需要调整更广泛的配置设置才能在我的情况下启用重写?我通常理解 ~folder 指的是用户的主目录,但我不知道它如何发挥作用或可以根据我的情况进行调整。

I am trying to do the following rewrite of tilde URLs:

RewriteRule ^/?~folder/(.*) http://whatever.com/$1 [R=302,L]

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

找回味觉 2024-12-08 04:43:33

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]

From: http://webmaster.iu.edu/tools-and-guides/maintenance/redirect-htaccess.phtml

我的影子我的梦 2024-12-08 04:43:33

正如您提到的,它可能与使用 mod_userdir 相关。请检查您的 apache 配置是否已激活,并查看禁用它是否可以解决问题。

http://httpd.apache.org/docs/2.2/mod/mod_userdir.html

It is probably linked to the use mod_userdiras you mention. Please check in your apache configuration if it is now activated and see if disabling it fixes the issue.

http://httpd.apache.org/docs/2.2/mod/mod_userdir.html

尴尬癌患者 2024-12-08 04:43:33

我使用此规则重定向以波浪号开头的所有内容

RewriteCond %{REQUEST_URI} ^/~([a-z]+)/
RewriteRule ^(.*)$ http://www.mysite.fr/$1 [R=301,L]

来自 @Sigg3.net 源: http://webmaster.iu.edu/tools-and-guides/maintenance/redirect-htaccess.phtml

I use this rule to redirect everything which starts with tilde

RewriteCond %{REQUEST_URI} ^/~([a-z]+)/
RewriteRule ^(.*)$ http://www.mysite.fr/$1 [R=301,L]

From @Sigg3.net source : http://webmaster.iu.edu/tools-and-guides/maintenance/redirect-htaccess.phtml

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文