htaccess 将所有页面重定向到单个页面 [英] htaccess redirect all pages to single page

查看:35
本文介绍了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 / http://www.thenewdomain.com/

推荐答案

您是否想让访问 old.com/about.htm 的访问者转到 new.com/about.htm?如果是这样,您可以使用 .htaccess 中的 mod_rewrite 规则执行此操作:

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

RewriteEngine on

重写规则 ^(.*)$ http://www.thenewdomain.com/$1 [R=permanent,L]

这篇关于htaccess 将所有页面重定向到单个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆