【问题标题】:Change a particular string in url using htaccess使用 htaccess 更改 url 中的特定字符串
【发布时间】:2015-11-12 19:59:28
【问题描述】:

我想更改我的网址

http://intervideo.2watt.net/component/content/article.html?id=65&Itemid=479

http://intervideo.2watt.net/component/content/article.html?id=65&Itemid=332

我尝试了以下代码,但它不起作用

RewriteRule ^/?Itemid=479/(.*)$ Itemid=332/$1 [R=301,L]

【问题讨论】:

    标签: regex apache .htaccess mod-rewrite redirect


    【解决方案1】:

    您无法从RewriteRule 捕获查询字符串。请改用RewriteCond

    RewriteCond %{QUERY_STRING} ^(id=\d+)&Itemid=479$ [NC]
    RewriteRule ^component/content/article\.html$ %{REQUEST_URI}?%1&Itemid=332 [L,NC,R=302]
    

    【讨论】:

    • 感谢您的回答::)
    猜你喜欢
    • 2012-09-03
    • 2018-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-26
    • 1970-01-01
    相关资源
    最近更新 更多