【问题标题】:how to 301 example.com/xxx/feed to example.com/xxx/ in htaccess如何在 htaccess 中 301 example.com/xxx/feed 到 example.com/xxx/
【发布时间】:2014-01-19 13:52:16
【问题描述】:

我需要使用 htaccess 删除 url 的提要。

我用RewriteRule ^[0-9]{4}/[0-9]{1,2}/[^/]+/feed/?$ /[R,L]

但它不能指向url

http://www.example.com/xxx/feed

到正确的网址

http://www.example.com/xxx/

我对 htaccess 了解不多。

如果你能告诉我怎么做或给我一些建议来学习如何做,真的很感谢你的帮助。

只需将 url:example.com/xxx/feed 重定向到 htaccess 中的 example.com/xxx/。

【问题讨论】:

    标签: regex apache .htaccess


    【解决方案1】:

    将您的规则简化为:

    RewriteEngine On
    RewriteRule ^(.+?)/feed/?$ /$1/ [L,R]
    

    或者使用RedirectMatch

    RedirectMatch 302 ^/(.+?)/feed/?$ /$1/
    

    【讨论】:

    • RedirectMatch 302 ^/(.+?)/feed/?$ /$1/ 为我工作~谢谢。祝你有美好的一天~
    猜你喜欢
    • 2014-09-21
    • 2023-03-04
    • 1970-01-01
    • 2011-12-13
    • 2014-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-24
    相关资源
    最近更新 更多