2017-04-14 47 views
0

當維護文件就位時,第一條規則正常工作。當它不是 - 第二條規則不是重定向到特定的URI。是否有規則的訂購問題?使用HTTPD.conf從根重定向到特定URI

######################################### 

    RewriteCond %{DOCUMENT_ROOT}/server_maintenance.html -f 
    RewriteCond %{REQUEST_FILENAME} !/server_maintenance.html 
    RewriteRule ^.*$ /server_maintenance.html [L] 

    ######################################### 
    ## the %{HTTP_HOST} evaluates to the HTTP header with the name given in this case host.server.org, with NC being non case sensitive. 
    ## it will rewrite the url at the server side to append the URI of lawson/portal 
    ########################################################################## 
    RewriteCond %{HTTP_HOST} ^host\.server\.org$ [NC] 
    RewriteRule ^host\.server\.org$ "https\:\/\/host\.server\.org\/lawson\/portal" [L] 

    ######################################### 

回答

0

你不會在重寫規則匹配的主機名,即使如此有更多的理由,如果你已經在先前定義的RewriteCond匹配它。

所以只是做:

RewriteCond %{HTTP_HOST} ^host\.server\.org$ [NC] 
RewriteRule^https://host.server.org/lawson/portal [L] 

注:重寫規則目標/目的不regix所以不需要逃避每一件小事。

注2:單^將匹配使用這種方法的任何

+0

- 我收到了以下問題:您沒有權限訪問/在此服務器上。 Options指令禁止的目錄索引:/ lsf10/webdocs/ – Configueroa

+0

如果您沒有索引或目錄索引集,您希望apache如何爲目錄提供服務? –