[英]Issue loading resources using mod_jk with httpd and tomcat
我有一個tomcat應用程序。 我也在使用apache服務器,並使用mod_jk將其連接到tomcat。 在這里,我使用了重寫模塊來更改URL,但是當我的網站運行時,頁面資源(css,js)無法正確加載。
我的tomcat應用程序名稱Mahmudul
。 我要創建網址www.mahmudul.com
,所以我配置了httpd.conf文件。 這是我的配置。
<VirtualHost *:80>
ServerName www.mahmudul.com
RewriteEngine on
RewriteRule ^/(.*)$ /Mahmudul/$1 [l,PT]
JkMount /* tomcat1
</VirtualHost>
如果我將URL配置為從www.mahmudul.com/Mahmudul
加載,則並非一切都正常,因為資源位置為/assets/css/styles/
。 但是我更改了上面的配置,以使URL為www.mahmudul.com
。 但現在資源/Mahmudul/assets/css/styles/
和資源的位置未加載。 同樣,當單擊任何鏈接(例如“聯系人”)時,鏈接顯示“ / Mahmudul / contact”,並且會話ID隨鏈接一起附加。 我想省略/Mahmudul
。 我怎樣才能做到這一點?
我已經解決了這個問題。 在這里,我不必重寫URL。 我使用了相同的虛擬主機配置,但沒有RewriteEngine。 我只需要配置tomcat server.xml並添加新的主機配置。 這是配置-
<Host name="mahmudul.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Alias>www.mahmudul.com</Alias>
<Context path="" docBase="Mahmudul-1.0-SNAPSHOT" debug="0" privileged="true" />
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" resolveHosts="false" />
</Host>
這是我的worker.properties
worker.list=tomcat1
worker.tomcat1.type=ajp13
worker.tomcat1.port=8009
worker.tomcat1.host=localhost
和我的apache httpd.conf虛擬主機配置
<VirtualHost *:80>
ServerName mahmudul.com
ServerAlias www.mahmudul.com
JkMount /* tomcat1
</VirtualHost>
希望對您有所幫助。 謝謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.