[英]Redirect a page from one domain to another domain (both domains belong to one website)
At first glanse question is pretty common, however other answers I have seen do not work in my case.乍一看问题很常见,但是我看到的其他答案在我的情况下不起作用。 I need to redirect a page from one domain to another domain.我需要将页面从一个域重定向到另一个域。 Both domains have one web-site under them and one common .htaccess file.这两个域下都有一个网站和一个通用的 .htaccess 文件。
www.olddomain.com/guides -> www.newdomain.com www.olddomain.com/guides -> www.newdomain.com
I use .htaccess file.我使用.htaccess文件。 If someone knows answer for other way - you are welcome also.如果有人知道其他方式的答案-也欢迎您。
My current file:我当前的文件:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([a-z_\d]+)$ controller.php?page=$1 [QSA]
I have tried this way:我试过这种方式:
RewriteEngine on
Redirect 301 http://www.olddomain.com/guides https://www.newdomain.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([a-z_\d]+)$ controller.php?page=$1 [QSA]
Also I tried this way:我也试过这种方式:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^http://www.olddomain.com/guides$ https://www.newdomain.com [R=301]
RewriteRule ([a-z_\d]+)$ controller.php?page=$1 [QSA]
Does not work.不起作用。 How it can be done properly?如何正确完成?
I believe your Redirect 301 line is the way to go, but should read something like this:我相信你的重定向 301 行是要走的路,但应该阅读如下内容:
Redirect 301 /guides https://www.newdomain.com
See here for more information.请参阅此处了解更多信息。
Edit to add: The above will redirect to https://www.newdomain.com/
编辑添加:以上将重定向到https://www.newdomain.com/
If you want a certain path, then just put如果你想要一条特定的路径,那么只要把
Redirect 301 /guides https://www.newdomain.com/foo
where foo is the path on the server you want to end up at.其中 foo 是您想要结束的服务器上的路径。
I end up with the following.我最终得到以下结果。
Redirect 301 /guides https://www.newdomain.com重定向 301 /guides https://www.newdomain.com
Now all traffic from the page "/guides" of olddomain will go to my newdomain.现在来自 olddomain 页面“/guides”的所有流量都将转到我的 newdomain。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.