【问题标题】:Apache Rewrite Rules for CentOS Grails Application with Tomcat使用 Tomcat 的 CentOS Grails 应用程序的 Apache 重写规则
【发布时间】:2014-03-06 19:07:10
【问题描述】:

我在 CentOS 机器上使用 Apache 和 Tomcat,我想做以下重写:

  1. 我想处理 abc.com 以在发出请求时重定向到 www.abc.com。
  2. 我想用 Apache 而不是 Tomcat 加载我的资源

这是我的 conf 文件。它位于 /etc/httpd/conf.d/tomcat.conf

#
# This configuration file enables the default "Welcome"
# page if there is no default index page present for
# the root URL.  To disable the Welcome page, comment
# out all the lines below.
#

RewriteEngine on
RewriteRule ^/images/(.*)    /images/$1
RewriteRule ^/css/(.*)    /css/$1
RewriteRule ^/js/(.*)    /js/$1

RewriteCond %{HTTP_HOST} ^abc\.com
RewriteRule ^(.*)$ http://www.abc.com$1 [R=301,L]

NameVirtualHost *:80
<VirtualHost *:80>
    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass / ajp://127.0.0.1:8009/
    ProxyPassReverse / ajp://127.0.0.1:8009/
    ProxyPassReverseCookiePath / /
</VirtualHost>

我的 AJP 代理重写工作正常,我只需要在上面进行以下重写。

【问题讨论】:

    标签: apache tomcat grails url-rewriting centos


    【解决方案1】:
    1. apache redirect from non www to www
    2. 要使用 apache 而不是 tomcat 加载资源,您可以:
      • 使用 apache mod_cache 模块,因此您可以通过缓存资源(css、js、图像)来显着减少 tomcat 负载
      • 在您的 Web 应用程序中添加 servlet 过滤器以设置 http 缓存标头以启用缓存

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-05
      • 2017-12-10
      • 2014-08-26
      • 1970-01-01
      • 2011-09-02
      • 2011-10-26
      相关资源
      最近更新 更多