【问题标题】:htaccess redirect adds additional ?videos=blablahtaccess 重定向添加了额外的 ?videos=blabla
【发布时间】:2013-08-14 21:49:49
【问题描述】:

我正在尝试重定向这种页面结构

example.com/y/T5INF08ZEdA/Miranda-Kerr-In-Hot-Water-with-Orlando-Bloom

到

example.com/s/Miranda-Kerr-In-Hot-Water-with-Orlando-Bloom

我的 htaccess 是

RewriteRule ^s/(.*)$ index.php?videos=$1

RedirectMatch 301 ^/?y/(.*)$ http://www.example.com/s/$2 [R=301,L]

但是,它会重定向到

example.com/s/T5INF08ZEdA?videos=T5INF08ZEdA/Miranda-Kerr-In-Hot-Water-with-Orlando-Bloom

执行此重定向的正确方法是什么?

【问题讨论】:

    标签: .htaccess redirect


    【解决方案1】:

    奇怪的是,您的 RedirectMatch 完全有效,因为没有第二个捕获组($2 应该是空白的)。

    尝试只使用 mod_rewrite,这两个指令可能会相互干扰:

    RewriteRule ^y/([^/]+)/(.*)$ /s/$2 [L,R=301]
    RewriteRule ^s/(.*)$ index.php?videos=$1 [L]
    

    【讨论】:

    • @user198989 如果您删除了RedirectMatch,那么还有其他导致重定向的原因,不是这两条规则。
    猜你喜欢
    • 2015-06-24
    • 2021-07-22
    • 2013-01-19
    • 1970-01-01
    • 1970-01-01
    • 2021-12-20
    • 2010-12-15
    • 1970-01-01
    • 2010-10-15
    相关资源
    最近更新 更多