簡體   English   中英

如何將所有流量重定向到一個域到另一個域的相同位置

[英]How can I redirect all traffic to one domain to the same location at another domain

我正在嘗試將所有流量重定向到一個域到另一個域。 無論位於哪個子域或目錄中。 它應該在另一個域中的相同位置。

zweeue.com-> zoeyt.com

s.zweeue.com-> s.zoeyt.com

zweeue.com/art/-> zoeyt.com/art/

現在這是技巧,在另一個域中,我有一個mod重寫,它將不存在的文件和目錄的所有流量發送到l.php

因此zoeyt.com/art存在,因此zweeue.com/art/會轉到zoeyt.com/art/

但是zweeue.com/mvs並非如此,因此zoeyt.com/mvs會訪問zoeyt.com/mvs/。 現在,zweeue.com / mvs收到404,但是zweeue.com/art/應該轉到zoeyt.com/art/,因為/ art /存在於此。 zweeue.com上的所有內容均通過以下第一個htaccess文件進入zoeyt.com。 下面的第二個mod重寫塊是zoeyt.com的單獨主機上的單獨htaccess文件

我該如何成功完成? 目前,zweeue.com / mvs轉到zoeyt.com/,而不是zoeyt.com/mvs,而zoeyt的htaccess會將其發送到l.php。

以下是第一個域zweeue.com的重定向htaccess中的內容:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^(.*)$ http://www.zoeyt.com/$1 [L,R=301]

</IfModule>

這是第二個域的htacccess文件(zoeyt)中的內容:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /l.php [L]
</IfModule>

將您的第一個.htaccess更改為此:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^ http://www.zoeyt.com%{REQUEST_URI} [L,R=301,NE]

</IfModule>

第二個域的htacccess文件(zoeyt):

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ l.php [L]

</IfModule>

使用%{REQUEST_URI}而不是$1可以確保發送完整的URI而不是定位在$1捕獲的相對值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM