2017-06-17 75 views
2

影響輔助域我有2個結構域:重定向主域到子文件夾中,而無需使用htaccess的

  • gyanplease.com/gyanplease主域(我已經改變了文檔根與.htaccess幫助下)
  • mobiledevsolutions.com輔助域

在我創建了一個名爲gyanplease文件夾,並用.htaccess的幫助下我已經重寫gyanplease.com文檔根目錄gyanplease該文件夾。這對重定向代碼:

#disable https 
RewriteEngine on 
RewriteCond %{HTTPS} on 
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
RewriteCond %{REQUEST_URI} !gyanplease/ 
RewriteRule (.*) /gyanplease/$1 [L] 

現在,當我在託管在同一臺服務器上的另一個領域,就是mobiledevsolutions.com,那麼它不工作,並給出了404重定向錯誤。

回答

1

你可以做的只是運行/gyanplease/重寫該主機,像這樣(將最後兩行):

RewriteCond %{HTTP_HOST} (?:^|\.)gyanplease.com$ 
RewriteCond %{REQUEST_URI} !^/gyanplease/ 
RewriteRule ^(.*)$ /gyanplease/$1 [L] 

這樣,這條規則只會影響gyanplease.com

您還可以更改4號線這一點,因爲沒有使用捕捉:

RewriteRule^http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

因此,所有這將使你的新規則:

RewriteEngine on 
# Disable HTTPS 
RewriteCond %{HTTPS} on 
RewriteRule^http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
# Rewrite gyanplease.com to /gyanplease/ 
RewriteCond %{HTTP_HOST} (?:^|\.)gyanplease.com$ 
RewriteCond %{REQUEST_URI} !^/gyanplease/ 
RewriteRule ^(.*)$ /gyanplease/$1 [L] 
相關問題