Apache Tomcat:apache + Tomcat +js + CSS implementation split Cross-domain

Source: Internet
Author: User
Tags split domain domain name access tomcat tomcat server apache tomcat

A Java site, using Tomcat server, you need to the site's CSS, images, JS need to separate. With a different domain name, you will encounter cross-domain situations. To do this, the Apache proxy is used to implement the detach work
CSS, images, JS resources all put to
src.test.com/css/...
Src.test.com/images/...
src.test.com/js/...
Java Site Tomcat Server access method
ajp://127.0.0.1:8009/
Actually, it's http://127.0.0.1:8080/.
Apache httpd.conf Configuration


ServerName mnr.test.com
Rewriteengine on
Rewriterule ^/(. *) ajp://127.0.0.1:8009/sub/$1 [P]


Then access the site through the http://sub.test.com way
Because CSS, images, JS resources are independent domain names, it may be on other servers, but must be in the subdomain domain name method to avoid cross-domain situation.


ServerName mnr.test.com
Rewriteengine on
proxypass/js/http://src.test.com/js/
proxypass/css/http://src.test.com/css/
proxypass/images/http://src.test.com/images/
Rewriterule (?! /((JS) (CSS) (img))/^.*$) ajp://127.0.0.1:8009/sub/$1 [P]



Restart Apache to
Call the corresponding relationship:
Sub.test.com/css src.test.com/css/...
Sub.test.com/images src.test.com/images/...
Sub.test.com/js src.test.com/js/...
sub.test.com resources are access to the resources under the Tomcat directory
This article links http://www.cxybl.com/html/wyzz/CSS/20121227/35249.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.