的.htaccess 301重定向旧域的所有网页上的新域单页

编程入门 行业动态 更新时间:2024-10-27 13:35:11
本文介绍了的.htaccess 301重定向旧域的所有网页上的新域单页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在找重定向的每个页面旧域到单页在新的领域。它也应该重定向无论是www和非www版本。每一个请求域old,无论是什么,应该引起www.new根。

I'm looking to redirect each and every page on the old domain to a single page on the new domain. It should also redirect both the www and non-www versions. Every single request to the domain old, whatever it may be, should lead to www.new root.

old/1.php www.old/2.php old/2.php old/links/index.php old/about-us.html old/?string=1

都应该重定向到:

should all redirect to:

www.new /

www.new/

我正在寻找一个解决方案的.htaccess

I'm looking for a .htaccess solution.

推荐答案

您可以在old虚拟主机使用RedirectMatch

You can use RedirectMatch in the old vhost

RedirectMatch permanent .* www.new/

重定向追加匹配的URI来重定向结尾部分URI,但 RedirectMatch 这是由你来选择您想要使用圆括号来转移部分(如有)及 $号引用。

Redirect appends the trailing portion of the matched URI to the redirection URI but with RedirectMatch it's up to you to choose the parts (if any) that you want to transfer using parentheses and $number references.

如果旧的和新的领域必须是别名磁盘上的同一个文档根目录,那么你可能需要使用mod_rewrite

If the old and new domains must be aliases for the same document root on disk then you'll probably have to use mod_rewrite

RewriteEngine on RewriteCond %{HTTP_HOST} old\$ RewriteRule .* www.new/ [L,R=301]

更多推荐

的.htaccess 301重定向旧域的所有网页上的新域单页

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

发布评论

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

>www.elefans.com

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