【问题标题】:wordpress htaccess url: add extension to 1 urlwordpress htaccess url:将扩展名添加到 1 个 url
【发布时间】:2014-01-27 01:48:09
【问题描述】:

这是原网址 http://www.mysite.com/product-feed/

它应该是 http://www.mysite.com/product-feed.xml

我的 Htaccess

RewriteEngine On
RewriteRule ^/?product-feed.xml$ /product-feed/ [L]

这不起作用。

【问题讨论】:

    标签: wordpress .htaccess url url-rewriting


    【解决方案1】:

    如果人们要去http://www.mysite.com/product-feed/,而他们应该去http://www.mysite.com/product-feed.xml,那么你的规则就是倒退。 RewriteRule(或Redirect)的语法是:

    RewriteRule <the pattern that matches the URL> <what the URL should be>
    

    所以它应该是这样的:

    RewriteRule ^product-feed/$ /product-feed.xml [L,R]
    

    【讨论】:

    • 我是 .htaccess 的新手,但不知道为什么你的答案是相反的:stackoverflow.com/a/11546348/3085310 :D
    • @Felix:他这样做是因为在那个问题的情况下,不会发生重定向。请注意您的答案中缺少 R 标志。然后检查另一个,这是一个别名,而不是重定向。但是,如果 /product-feed/ 是向用户显示提要的实际 URL,那么您需要使用另一个。事实上,您可以同时使用两者。
    猜你喜欢
    • 2012-04-15
    • 1970-01-01
    • 2012-02-06
    • 2010-12-14
    • 2022-01-25
    • 1970-01-01
    • 2021-09-09
    • 2015-12-21
    • 1970-01-01
    相关资源
    最近更新 更多