简体   繁体   English

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

[英]How to serve static files using apache?

I have configured apache 2.2 webserver with tomcat. 我已经用Tomcat配置了Apache 2.2 Web服务器。 I want static files of my web application to be served using apache. 我希望使用apache来提供Web应用程序的静态文件。 I made a virtual host entry in httpd.conf 我在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>

But when i fetch this file in browser http://myexample.net:8080/webcommon/img/aboutBox.png i get Object not found! 但是,当我在浏览器http://myexample.net:8080/webcommon/img/aboutBox.png中获取此文件时,找不到对象! The requested URL was not found on this server. 在此服务器上找不到请求的URL。

Try this instead: 尝试以下方法:

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM