將子網域重新導向到不同的登入頁面

將子網域重新導向到不同的登入頁面

我的 vhost.conf 檔案中有一個帶有子網域設定的網域,如下所示。

<VirtualHost *:80>
    ServerName mysite.com
    ServerAlias www.mysite.com
    DocumentRoot /opt/mysite/webapps/ROOT/
    ProxyPassMatch / ajp://localhost:8084
</VirtualHost>

<VirtualHost *:80>
    ServerName subdomain.mysite.com 
    ServerAlias www.subdomain.mysite.com
    DocumentRoot /opt/mysite/webapps/ROOT/
    Redirect /index.jsp /index2.jsp
    ProxyPassMatch / ajp://localhost:8084
</VirtualHost>

主網站加載,index.jsp但我希望子網域加載不同的 JSP 檔案 ( index2.jsp)。

我嘗試過使用重定向,但它只是轉到index.jsp子網域。

答案1

編輯

由於 的存在,以下內容是錯誤的ProxyPassMatch

自從我上次設定 Apache VirtualHost 以來已經很久了,但我認為

DirectoryIndex index2.jsp

這就是您正在尋找的。

因此,完整的配置將是:

<VirtualHost *:80>
    ServerName subdomain.mysite.com 
    ServerAlias www.subdomain.mysite.com
    DocumentRoot /opt/mysite/webapps/ROOT/

    # Serve index2.jsp as index file
    DirectoryIndex index2.jsp

    ProxyPassMatch / ajp://localhost:8084
</VirtualHost>

編輯

我看起來不夠仔細,看起來該ProxyPassMatch指令覆蓋了許多其他命令:

As the ProxyPassMatch directive is evaluated as the very beginning of each request:
  -AddType (for MultiView) or DirectoryIndex directives are not usable
  -right management per directory is not available
  -each Alias directive needs another proxy rule

問題是你的index2.jsp意願絕不由 Apache 提供服務,因為伺服器已經與 ProxyPass / 匹配,因此它已經被傳遞到ajp://localhost:8084.

然後您應該管理服務index.jsp或。index2.jspajp://localhost:8084

相關內容