2016-11-30 152 views
0

到子文件夾我有一個域即www.domain.org並希望將它指向我的服務器上的子文件夾。從/的public_html和主域負載現在,我想從加載/的p​​ublic_html/domain2017域。使用的.htaccess指向主域,而無需改變URL

我研究了網絡上的各種解決方案,但我得到的只是一個重定向。 重定向是不可取的,因爲我結束了www.domain.org/domain2017時,我想留下來作爲www.domain.org但加載www.domain.org/domain2017的index.php文件。我們希望,這是有道理的。注:我的public_html/domain2017內的WordPress安裝。

下面是我的.htaccess的例子內容

<IfModule mod_rewrite.c> 
RewriteEngine On 

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.org$ [NC] 
RewriteRule !^subdir/ /domain2017%{REQUEST_URI} [L,NC] 
</IfModule> 

Solution Attempt 1Solution Attempt 2Solution Attempt 3Solution Attempt 4

我已經嘗試了所有上面的鏈接,他們只是我的域名重定向到URL並不會阻止URL在地址欄中改變

回答

0

你可以使用下面的htaccess:

RewriteEngine on 

RewriteCond %{HTTP_HOST} ^yourdomain.com$ [NC,OR] 
RewriteCond %{HTTP_HOST} ^www.yourdomain.com$ 
RewriteCond %{REQUEST_URI} !public_html/domain2017/ 
RewriteRule (.*) /public_html/domain2017/$1 [L] 
+0

我收到以下錯誤 未找到 在此服務器上找不到請求的URL /public_html/.....2017/。 此外,嘗試使用ErrorDocument處理請求時遇到404 Not Found錯誤。 –