rewrite rule needed for subdomains

Igor Sysoev is at rambler-co.ru
Wed Nov 4 00:35:27 MSK 2009


On Tue, Nov 03, 2009 at 10:19:09PM +0100, Mike Smith wrote:

> Igor Sysoev wrote:
> > On Tue, Nov 03, 2009 at 09:03:22PM +0100, Mike Smith wrote:
> > 
> >>     RewriteCond %{HTTP_HOST} !^(host)\.domain\.com [NC]
> >> to the end till it kills the loop
> >> 
> >>         if ($http_host !~ "^www.domain\.com$") {
> >>             rewrite ^.+ http://$http_host/magento/$uri last;
> >>             break;
> >>         }
> > 
> >     server {
> >         # a catchall server for "listen 80",
> >         # since it's "default" server for "listen 80"
> > 
> >         listen 80 default;
> >         server_name  store1.domain.com;
> > 
> >         location / {
> >             rewrite ^   http://$host/magento/$request_uri? last;

Probably, you need

-               rewrite ^   http://$host/magento/$request_uri? last;
+               rewrite ^   /magento$uri  last;

> >         }
> > 
> >         location /magento/ {
> >             ...
> >         }
> >     }
> > 
> >     server {
> >         listen 80;
> >         server_name  www.domain.com  host.domain.com;
> >         ...
> >     }
> 
> That works but it changes the browser URL and adds /magento/ in there 
> and that can't happen
> 
> When I go to http://store1.domain.com/products/
> 
> it gets changed to http://store1.domain.com/magento/products/
> 
> I just need the /magento/index.php to parse it via the URI


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list