簡體   English   中英

htaccess將整個域/文件夾重定向到另一個域

[英]htaccess redirect entire domain/folder to another domain

我不是htaccess的朋友,遇到了我似乎無法用Google解決的問題。 因此,希望你們能提供幫助。

我在那里,我想所有重定向到TRAFIC一個mydomain.com/anothersite多站點安裝目錄(和所有子文件夾和查詢字符串),以anothersite.com,並在同一時間必須anothersite.com重寫所有請求請求服務器查找anothersite文件夾。

基本上,服務器文件夾設置如下:在根,我們有我們有一個文件夾“anothersite”根網站包含其他網站

因此,對mydomain.com的所有請求都應顯示根文件夾,而對anothersite.com的所有請求應被重寫。

希望有道理

這是我所擁有的(它幾乎可以正常工作,但是效果不佳)

RewriteEngine on
RewriteBase /
RewriteRule ^mydomain\.com/anothersite(.*)$ http://anothersite.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^(www.)?anothersite.com$
RewriteRule !^anothersite/ anothersite%{REQUEST_URI} [L]

問題在於,對mydomain.com/anothersite/someFolderOrQuerystring的請求未重定向,而mydomain.com/anothersite/

希望有道理

(順便說一句:如果有人可以將我指向一本書的方向,那將使我成為htaccess文件奧秘的主人,這將是可喜的收獲。

在網站根目錄.htaccess中有以下規則:

RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ [NC]
RewriteRule ^anothersite(/.*)?$ http://anothersite.com%{REQUEST_URI} [NE,L,R=301]

RewriteCond %{HTTP_HOST} ^(www\.)?anothersite\.com$ [NC]
RewriteRule !^anothersite/ anothersite%{REQUEST_URI} [L,NC]

確保您在anothersite/文件夾下沒有任何.htaccess。

暫無
暫無

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

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