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

查看:143
本文介绍了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

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

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

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

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