Joyent

mod_rewrite on virtual subdomains

When using virtual subdomains, you may hit strange issues with mod_rewrite rules. More specifically, you will see rules being ignored. This is a problem with the way how Apache deals with requests coming for the subdomains (which are handled by a 3rd party mod_vd Apache module).

There is a workaround though: save the rules in the parent context, and prepend them with a hostname condition. Let’s say you need a rewrite rule to handle clean URLs for blog.domain.com, which is served by a Textpattern installation at the following location:

/users/home/myaccount/domains/domain.com/web/public/blog

You’d create a .htaccess here:

/users/home/myaccount/domains/domain.com/web/public

and construct the rewrite rule in the following manner:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^blog\.
RewriteRule (.*) /index.php [L]

MultiViews and subdomains

A related problem is that mod_vd prevents Apache MultiViews from working. Test this by trying the non-subdomain URL, eg if your intended URL is:

http://subdomain.domain.com/test

(using content negotiation to go to test.en.html or test.ja.html), try

http://www.domain.com/subdomain/test

Currently the only known workaround is to not use subdomain-style URLs for MultiViews content.

Using Rewrite to setup a quick webmail system

This is an easy way to setup a “webmail.domain.com” and have it also work with “www.domain.com/webmail” so it’ll send you to usermin.joyent.us/servername for the built-in webmail system with Joyent.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^webmail\.
RewriteRule (.*) https://usermin.joyent.us/magnolia [L]

Redirect /webmail https://usermin.joyent.us/magnolia
 
shared/kb/rewrite-subdomains.txt · Last modified: 2008/02/05 03:13 by iguy
 
Recent changes RSS feed Creative Commons License Driven by DokuWiki