Mobile app version of vmapp.org
Login or Join
Frith620

: Apache URL rewriting with masking and includes outside of DocumentRoot I have an Apache 2.2.15 web server with the primary site at /web/mybiz which corresponds to http://mybiz.domain.com. We now

@Frith620

Posted in: #Apache #Masking #ModRewrite #UrlRewriting

I have an Apache 2.2.15 web server with the primary site at /web/mybiz which corresponds to mybiz.domain.com. We now have a new subdomain abc.mybiz.domain.com with the homepage living at /web/mybiz/abc/index.html.

Currently, I have a simple rewrite so when people visit abc.mybiz.domain.com, they get redirected to mybiz.domain.com/abc/index.html. The includes for that homepage live in /web/mybiz/static and /web/mybiz/images.

I need to have it so that people visiting don't see the URL change in the browser, but I cannot figure out how to make it work and keep the includes all working.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Frith620

1 Comments

Sorted by latest first Latest Oldest Best

 

@Gloria169

The use of a rewrite condition along with a rule to map transparently to the subdirectory should work.

RewriteCond %{HTTP_HOST} ^abc.mybiz.domain.com$ [NC]
RewriteCond %{REQUEST_URI} ^(/|.*.html)$ [NC]
RewriteRule ^/(.*)$ /abc/ [L]


Now when a request for abc.mybiz.domain.com/ or abc.mybiz.domain.com/index.html is made it will be pulled from the /abc/ subdirectory. This also covers any request for an .html file. Your includes (images/css/javascript)? should be pulled in from their real locations just fine.
httpd.apache.org/docs/2.2/mod/mod_rewrite.html

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme