如何使用apache提供静态文件?

时间:2014-03-11 10:58:47

标签: apache tomcat mod-rewrite mod-jk

我已经使用tomcat配置了apache 2.2 webserver。我希望使用apache来提供我的Web应用程序的静态文件。我在httpd.conf中创建了一个虚拟主机条目

<VirtualHost *:8080>
Alias webcommon_alias C:/webcommon_bk

JkMountFile D:/xampp/apache/conf/myexample.net.properties
ServerName myexample.net
ErrorLog logs/myexample.net-error_log
CustomLog logs/myexample.net-access_log common

<Directory C:/webcommon_bk>
    Order allow,deny
    Allow from all
    RewriteEngine On
    RewriteBase /webcommon/
    RewriteRule ((.*)\.(js|css|html|gif|png)$) webcommon_alias/$1
</Directory>    

</VirtualHost>

但是当我在浏览器http://myexample.net:8080/webcommon/img/aboutBox.png中获取此文件时,我找不到对象!在此服务器上找不到请求的URL。

1 个答案:

答案 0 :(得分:0)

请改为尝试:

<VirtualHost *:8080>
Alias /webcommon C:/webcommon_bk

JkMountFile D:/xampp/apache/conf/myexample.net.properties
ServerName myexample.net
ErrorLog logs/myexample.net-error_log
CustomLog logs/myexample.net-access_log common

<Directory C:/webcommon_bk>
    Order allow,deny
    Allow from all
    RewriteEngine On
    RewriteRule ((.*)\.(js|css|html|gif|png)$) /webcommon/$1.$2
</Directory>    

</VirtualHost>