1

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 have a new subdomain http://abc.mybiz.domain.com with the homepage living at /web/mybiz/abc/index.html.

Currently, I have a simple rewrite so when people visit http://abc.mybiz.domain.com, they get redirected to http://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.

  • Are you using .htaccess or adding your rewrite in apache config? – Dave Lozier Jul 17 '14 at 0:37
  • In the apache config. – Gregg Leventhal Jul 17 '14 at 18:17
1

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/$1 [L]

Now when a request for http://abc.mybiz.domain.com/ or http://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.

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.