【问题标题】:Htaccess 301 redirect is adding ?folder= to URLHtaccess 301 重定向正在将 ?folder= 添加到 URL
【发布时间】:2014-04-04 11:13:27
【问题描述】:

我正在尝试通过 htaccess 执行简单的 301 重定向,重定向有效,但在 URL 中添加了“?folder=X”。

例如:

Redirect 301 /pets http://www.mydomain.com/discount-pet-products

返回:

http://www.mydomain.com/discount-pet-products?folder=pets

如何删除?

这是我的 htaccess 文件

Options +FollowSymLinks
RewriteEngine On 
RewriteBase / 
Redirect 301 /pets http://www.mydomain.com/discount-pet-products
RewriteRule ^([0-9a-zA-Z-]+)$ load.php?folder=$1 [L]

【问题讨论】:

  • 让你想要 X url 到 Y。那么 x & y 是什么?
  • 抱歉,这个问题我没看懂?
  • 也许您有一个包含folder=X 的查询字符串?是这样,这将有助于stackoverflow.com/questions/10708301/…

标签: php apache .htaccess mod-rewrite redirect


【解决方案1】:

试试这个:

Options +FollowSymLinks
RewriteEngine On 
RewriteBase / 
RewriteRule ^/pets$ http://www.mydomain.com/discount-pet-products? [R=301,L]
RewriteRule ^([0-9a-zA-Z-]+)$ load.php?folder=$1 [L]

【讨论】:

  • 谢谢,但没有运气:(
【解决方案2】:

试试这个代码:

Options +FollowSymLinks
RewriteEngine On 
RewriteBase / 

RewriteRule ^pets/$ /discount-pet-products? [R=301,L]

RewriteRule ^([0-9a-zA-Z-]+)/?$ load.php?folder=$1 [L,QSA]

确保在新浏览器中对此进行测试以避免浏览器缓存问题。

【讨论】:

    【解决方案3】:

    答案是将重定向放在 .htaccess 文件的顶部,在任何东西之前

    RewriteRule ^pets$ http://www.mydomain.co.uk/discount-pet-products [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 2013-01-09
      • 2011-10-10
      • 2013-04-17
      • 2014-01-14
      • 2010-12-15
      • 1970-01-01
      • 2013-12-21
      • 2015-03-04
      • 1970-01-01
      相关资源
      最近更新 更多