如何在保留路径的同时 301 重定向整个域

编程入门 行业动态 更新时间:2024-10-15 22:23:47
本文介绍了如何在保留路径的同时 301 重定向整个域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在将一个域重定向到另一个域,但我想保留重定向中的路径.例如,我想访问 www.example/services/education/page.html,但我的重定向会将它们带到 www.new-example/services/education/page.html.我在我的 .htaccess 文件中写了什么来保留路径/services/education/page.html"?

I am redirecting one domain to another, but I want to preserve the path in the redirect. So for example, I want to visit www.example/services/education/page.html, but my redirect will bring them to www.new-example/services/education/page.html. What do I write in my .htaccess file to preserve the path "/services/education/page.html"?

现在我有:

redirect 301 www.example/ www.new-example/

但我不确定这是否有效(由于我正在等待域详细信息等,因此无法进行测试).我只是想确定我何时将网站上线.是这样还是我离基地很远?

But I'm not sure if that works or not (Can't test yet as I am waiting for domain details etc). I just want to be sure when I put the site live. Is that right or am I way off base?

谢谢!

推荐答案

应该这样做:

RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !new-example$ [NC] RewriteRule ^(.*)$ new-example/$1 [L,R=301]

更多推荐

如何在保留路径的同时 301 重定向整个域

本文发布于:2023-10-31 13:53:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546280.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路径   重定向   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!