【问题标题】:How to do a 301 redirect for an index.php?dynamic=url如何为 index.php 进行 301 重定向?dynamic=url
【发布时间】:2015-05-27 15:32:07
【问题描述】:

我有 1 个旧的 index.php?etc_etc URL 我想转发到一个特定的 URL,但是 301 重定向不起作用。

我的重写条件是:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=301]

我一直在使用这种格式来重写 URL。

redirect 301 /index.php?page=shop.product_details&flypage=flypage.tpl&product_id=948&category_id=114&option=com_virtuemart&Itemid=69 /739619-5004s-garrett-gtp38r-ball-bearing-turbo-kit-99-5-03-7-3l-power-stroke

这不起作用。我想是因为 Magento 使用 index.php 作为主页。

如何将该 URL 永久重定向到新的。

【问题讨论】:

    标签: .htaccess redirect


    【解决方案1】:

    您无法匹配 Redirect 指令中的查询字符串。您需要使用 mod_rewrite 并匹配条件中的 %{QUERY_STRING} 变量。所以在RewriteEngine On下面,添加:

    RewriteCond %{QUERY_STRING} ^page=shop.product_details&flypage=flypage.tpl&product_id=948&category_id=114&option=com_virtuemart&Itemid=69
    RewriteRule ^index\.php$ /739619-5004s-garrett-gtp38r-ball-bearing-turbo-kit-99-5-03-7-3l-power-stroke? [L,R=301]
    

    【讨论】:

    • 你有一个错字,上面写着“^age”,应该是“page”。然而,现在得到一个重定向循环错误。 ERR_TOO_MANY_REDIRECTS
    • @TravisHarshaw 修正了错字,我也忘记了规则目标末尾的?。这可以防止查询字符串被附加到末尾。
    猜你喜欢
    • 2020-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-26
    • 2014-01-14
    • 1970-01-01
    • 2013-02-22
    相关资源
    最近更新 更多