【问题标题】:.htaccess redirect with percents in the URL.htaccess 在 URL 中使用百分比重定向
【发布时间】:2014-12-04 17:02:52
【问题描述】:

在将一些旧 URL 重写为同一域上的新 URL 时遇到问题,最好尝试仅使用本地 URL。

使用百分比的未编码符号是否会导致问题?

旧网址

http://domain.com/Delta_%26_Charlie_Alfa/Delta_%26_Charlie_Alfa.html

新网址

http://domain.com/areas-groups/view/delta-charlie-alfa

重写规则

RewriteRule ^Delta_%26_Charlie_Alfa/Delta_%26_Charlie_Alfa.html /areas-groups/view/delta-charlie-alfa [R=301,NC,L,B,PT]

我用NC 表示无案例,用B 尝试逃避百分比?

【问题讨论】:

  • %26 编码为&,而不是百分比
  • 是的,但这仍然适用于未编码的字符吗?不幸的是,我无法更改旧网址,因为它是客户网站,我们无法更改旧网址...

标签: .htaccess mod-rewrite rewrite


【解决方案1】:

你可以使用这条规则:

RewriteRule ^Delta_\x26_Charlie_Alfa/Delta_\x26_Charlie_Alfa\.html$ /areas-groups/view/delta-charlie-alfa [R=302,NC,L,B]

\x26 匹配 %26

【讨论】:

  • 给出错误,下划线是否需要转义?
  • 不,它适用于我的 Apache。你有什么 Apache 版本,你遇到了什么错误?
猜你喜欢
  • 2016-02-01
  • 2016-05-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-17
  • 1970-01-01
  • 2013-12-05
相关资源
最近更新 更多