[英]Redirect a page from one domain to another domain (both domains belong to one website)
乍一看問題很常見,但是我看到的其他答案在我的情況下不起作用。 我需要將頁面從一個域重定向到另一個域。 這兩個域下都有一個網站和一個通用的 .htaccess 文件。
www.olddomain.com/guides -> www.newdomain.com
我使用.htaccess文件。 如果有人知道其他方式的答案-也歡迎您。
我當前的文件:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([a-z_\d]+)$ controller.php?page=$1 [QSA]
我試過這種方式:
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]
我也試過這種方式:
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]
不起作用。 如何正確完成?
我相信你的重定向 301 行是要走的路,但應該閱讀如下內容:
Redirect 301 /guides https://www.newdomain.com
請參閱此處了解更多信息。
編輯添加:以上將重定向到https://www.newdomain.com/
如果你想要一條特定的路徑,那么只要把
Redirect 301 /guides https://www.newdomain.com/foo
其中 foo 是您想要結束的服務器上的路徑。
我最終得到以下結果。
重定向 301 /guides https://www.newdomain.com
現在來自 olddomain 頁面“/guides”的所有流量都將轉到我的 newdomain。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.