htaccess将旧链接重定向到新域 [英] htaccess redirect old links to new domain
本文介绍了htaccess将旧链接重定向到新域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我更改了站点域,并希望将旧网址重定向到新域
I changed my site domain, and want to redirect old urls to new domain
(注意:代替数字93、54可能存在任何数字)
旧网址是:
(note: instead of numbers 93, 54 maybe any digit number exists) the old urls are:
http://olddomain.com/
http://olddomain.com/45
http://olddomain.com/p/93
新网址是:
http://newdomain.com/
http://newdomain.com/45
http://newdomain.com/p/93
我在htaccess上尝试过此操作:
I tried this at htaccess:
RewriteEngine on
RewriteCond %{REQUEST_URI}
RewriteRule http://newdomain.com/
RewriteCond %{REQUEST_URI} (\d+)/
RewriteRule (\d+)/ http://newdomain.com/$1
RewriteCond %{REQUEST_URI} p/(\d+)/
RewriteRule p/(\d+)/ http://newdomain.com/p/$1
但不起作用:(
此外,cpanel调用方可以选择重定向
我可以重定向您到新的旧链接唱吧。
感谢您的帮助
In addition, there is a choice at cpanel caller Redirects can I redirect the old links to new by using it. thanks for help
推荐答案
这应该有效:
RewriteEngine On
RewriteRule ^(.*) http://newdomain.com/$1 [R=301]
它将所有页面从旧网站重定向到新网站。
It will redirect all pages from the old website to the new website.
这篇关于htaccess将旧链接重定向到新域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文