htaccess将所有页面重定向到单页

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

我想使用htaccess文件将我所有的旧域名请求重定向到我的新域。以下是我正在使用的,但如果该网页不在新网站上,则无效。例如,在旧站点上的google index about.htm,但是在新站点上它不存在。在所有情况下,我都希望它能够根深蒂固。我知道这不是理想的seo,但我不想要任何404。任何建议?

I want to redirect all of my old domain request to my new domain using htaccess file. Below is what I am using but it does not work if the page is not on the new site. For example google index about.htm on the old site but on the new site it does not exist. I would like it to just go to the root in all cases. I know this is not ideal for seo but I don't want any 404s. Any suggestions?

Redirect 301 / www.thenewdomain/

推荐答案

您是否想访问old/about.htm以访问new/ about.htm中?如果是这样,可以使用.htaccess中的mod_rewrite规则:

Are you trying to get visitors to old/about.htm to go to new/about.htm? If so, you can do this with a mod_rewrite rule in .htaccess:

RewriteEngine on

RewriteRule ^(。*)$ www.thenewdomain/$1 [R = permanent,L] code>

RewriteRule ^(.*)$ www.thenewdomain/$1 [R=permanent,L]

更多推荐

htaccess将所有页面重定向到单页

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

发布评论

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

>www.elefans.com

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