重定向 301 未按我预期的方式工作!

发布于 2024-11-06 15:51:24 字数 998 浏览 0 评论 0原文

尝试使用以下代码通过 htaccess 获得简单的 301 重定向: 重定向 301 /cat/radiator-cages/product/radiator-support-cage/ http://www.mysite.com/product/radiator-cages/custom-radiator-support-cage/

结果将我发送到 http://www.mysite.com/product/radiator-cages/custom-radiator-support-cage/?page=cat/radiator-cages/product/radiator-support-cage

知道我是什么吗做错了吗? 预先感谢您的任何帮助。

- 更新 -

RewriteCond %{HTTP_HOST} ^mysite.com [NC] 
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
RewriteRule ^product/(.*)/(.*)/$ /index.php?page=product&parent_url=$1&product=$2 [L,NC]

Redirect 301 /cat/radiator-cages/product/radiator-support-cage/ http://www.mysite.com/product/radiator-cages/custom-radiator-support-cage/

Trying to get a simple 301 redirect with htaccess using this code:
Redirect 301 /cat/radiator-cages/product/radiator-support-cage/ http://www.mysite.com/product/radiator-cages/custom-radiator-support-cage/

The results are sending me to
http://www.mysite.com/product/radiator-cages/custom-radiator-support-cage/?page=cat/radiator-cages/product/radiator-support-cage

Any idea what I'm doing wrong?
Thanks in advance for any help.

--Update--

RewriteCond %{HTTP_HOST} ^mysite.com [NC] 
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
RewriteRule ^product/(.*)/(.*)/$ /index.php?page=product&parent_url=$1&product=$2 [L,NC]

Redirect 301 /cat/radiator-cages/product/radiator-support-cage/ http://www.mysite.com/product/radiator-cages/custom-radiator-support-cage/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

她如夕阳 2024-11-13 15:51:24

我建议首先尝试使用 Redirect 301 语句。

然后你的 htaccess 应该看起来像这样

    Redirect 301 /cat/radiator-cages/product/radiator-support-cage/ http://www.mysite.com/product/radiator-cages/custom-radiator-support-cage/
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^mysite.com [NC] 
    RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
    RewriteRule ^product/(.*)/(.*)/$ /index.php?page=product&parent_url=$1&product=$2 [L,NC]

编辑:

   RewriteEngine on
   RewriteCond %{HTTP_HOST} ^mysite.com [NC] 
   RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
   RewriteRule ^/cat/radiator-cages/product/radiator-support-cage/$ http://www.mysite.com/product/radiator-cages/custom-radiator-support-cage/ [R=301,L]
   RewriteRule ^product/(.*)/(.*)/$ /index.php?page=product&parent_url=$1&product=$2 [L,NC] 

http: //www.gerronmulder.com/common-seo-rewrite-rules-for-apache-using-htaccess/

I suggest trying to use the Redirect 301 statement first.

Your htaccess should then look somthing like this

    Redirect 301 /cat/radiator-cages/product/radiator-support-cage/ http://www.mysite.com/product/radiator-cages/custom-radiator-support-cage/
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^mysite.com [NC] 
    RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
    RewriteRule ^product/(.*)/(.*)/$ /index.php?page=product&parent_url=$1&product=$2 [L,NC]

Edit:

   RewriteEngine on
   RewriteCond %{HTTP_HOST} ^mysite.com [NC] 
   RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
   RewriteRule ^/cat/radiator-cages/product/radiator-support-cage/$ http://www.mysite.com/product/radiator-cages/custom-radiator-support-cage/ [R=301,L]
   RewriteRule ^product/(.*)/(.*)/$ /index.php?page=product&parent_url=$1&product=$2 [L,NC] 

http://www.gerronmulder.com/common-seo-rewrite-rules-for-apache-using-htaccess/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文