的.htaccess 301旧域名重定向到新的领域,而页面和URL结构是相同的 [英] .htaccess 301 redirect from old domain to new domain while structure of pages and url are same

查看:207
本文介绍了的.htaccess 301旧域名重定向到新的领域,而页面和URL结构是相同的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要重定向 http://olddomain.com HTTP:/ /newdomain.com 为我所有的urls..keeping页面上相同的新领域。 我的意思是说的网址,如以下

I want to redirect http://olddomain.com to http://newdomain.com for my all urls..keeping the page on new domain same. What i mean to say is URLs such as below

http://olddomain.com/home/category/page.html
http://olddomain.com/home/mybook/page2.html
http://olddomain.com/login

should be 301 redirect to the new newdomain but same pages, like below

http://newdomain.com/home/category/page.html
http://newdomain.com/home/mybook/page2.html
http://newdomain.com/login

这是我在我的.htaccess目前

this is what i have in my .htaccess currently

RewriteEngine on
RewriteCond $1 !^(index\.php|img|public|robots\.txt) [NC]
RewriteRule ^(.*)$ /index.php?/$1 [L]

请帮我做这件事干净,exlpain事情的细节,因为我是新本。

Please help me to do this cleanly and exlpain things in details since i am new in this.

也没有人知道多少时间,搜索引擎可能需要从我olddomain重定向的引用搬走?我的意思是在搜索查询中的老域名的URL应该用新域的网址被替换,...​​,N旧域应该从搜索引擎消失。

also does someone know how much time search engines might take to move away from the references of my olddomain? i mean the old-domain urls in search queries should be replaced by new-domain urls... n old domain should go away from search engines.

推荐答案

添加以下code处的.htaccess的开始 -

Add following code at the beginning of .htaccess -

    RewriteEngine On

    # Redirect Entire Site to New Domain
    RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
    RewriteCond %{HTTP_HOST} ^another.olddomain.com$ [NC]
    RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]

这篇关于的.htaccess 301旧域名重定向到新的领域,而页面和URL结构是相同的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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