rewrite rule needed for subdomains

Mike Smith lists at
Tue Nov 3 23:03:22 MSK 2009

We have a lot of magento stores that work like

so a user can go into and the url will stay

We do this in apache like

    RewriteCond %{HTTP_HOST} !^(host)\.domain\.com [NC]
    RewriteCond %{HTTP_HOST} !^(www)\.domain\.com [NC]
    RewriteRule ^(.*) /magento/$1 [L]

We also have a dns catchall that will send all * to a default
apache vhost. I'm slamming my head against the wall to get it working in
nginx to keep the hostname the same but behind the scenes rewrite the
domain for magento to parse.

Here is what I have but it just keeps appending /magento/magento/magento
to the end till it kills the loop

        if ($http_host !~ "^www.domain\.com$") {
            rewrite ^.+ http://$http_host/magento/$uri last;

Posted via

More information about the nginx mailing list