1

我正在尝试根据 url 条件将 http 请求重定向到 tomcat 或默认 DocumentRoot。

例子:

IF url contains /css/ then serving the file from /var/www
else
redirect to tomcat using JKMount

这是httpd.conf中的配置

<VirtualHost *:80>
     ServerName www.example.com
     DocumentRoot /var/www
     RewriteEngine on 
     LogLevel debug
     RewriteLogLevel 3
     RewriteLog logs/apache-mod_rewrite

     RewriteRule ^/css/(.*)$ /var/www/css/$1 [L]

     RewriteCond $1 !^portal
     RewriteRule ^/(.*)$ /portal/?user=YES [L,PT]
     JkMount  /* failover
</VirtualHost>

当尝试向http://www.example.com请求时,它会重定向到 tomcat 并正确提供页面。

但是,当尝试请求http://www.example.com/css/sample.css时,apache 返回错误 404。我是否可以将条件转发到默认 DocumentRoot 或 tomcat?先谢谢了。

4

0 回答 0