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

查看:305
本文介绍了htaccess的重定向所有页面单页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用htaccess文件重定向我所有的旧域名请求,我的新域名。下面是我使用的是什么,但它不工作,如果页面无法在新网站上。例如谷歌在老站点索引about.htm中,但在新网站上不存在。我想它只是去根在所有情况下。我知道这是不是理想的搜索引擎优化,但我不希望任何404。有什么建议?

 重定向301 / http://www.thenewdomain.com/
 

解决方案

您试图让游人old.com/about.htm~~V去new.com/about.htm~~V?如果是的话,你可以在.htaccess一个mod_rewrite的规则做到这一点:

  

RewriteEngine叙述上

     

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

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/

解决方案

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]

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

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