Welcome! Log In Create A New Profile

Advanced

Re: rewrite rules issue

Francis Daly
April 19, 2015 07:06AM
On Sun, Apr 19, 2015 at 04:06:55AM -0400, nicocolt wrote:

Hi there,

> Here is the directory path:
>
> /var/www/domain.fr/web/subdomain/directory
>
> my nginx conf is:
>
> root /var/www/domain.fr/web
>
> if ($http_host = "subdomain.domain.fr") {
> rewrite ^(?!/\b(subdomain|stats|error)\b)/(.*)$ /subdomain/$2
> last;
> }
>
> The if statement is before all of location directives.
>
> After purging my cache browser, this is what I get:
>
> when i reach http://subdomain.domain.fr/directory i'm redirected to
> http://subdomain.domain.fr/subdomain/directory (this is not what i want, i
> want http://subdomain.domain.fr/directory)

Ok, this makes a bit more sense now: your request actually might use
the configuration shown.

Are you sure that you have copy-pasted exactly the response? I would have
expected a redirect to http://subdomain.domain.fr/subdomain/directory/
-- but the actual redirect comes from the configuration that you have
not yet shown.

Your rewrite says that you *do* want the request to be handled like
http://subdomain.domain.fr/subdomain/directory, so I'm still not sure
what the actual full end intention is.

It does look to me like

server_name subdomain.domain.fr;
root /var/www/domain.fr/web/subdomain;

is probably what you really want, but I guess there is some reason why
you don't just use that?

Good luck with it,

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

rewrite rules issue

nicocolt April 18, 2015 04:08PM

Re: rewrite rules issue

Francis Daly April 18, 2015 05:04PM

Re: rewrite rules issue

nicocolt April 19, 2015 04:06AM

Re: rewrite rules issue

Francis Daly April 19, 2015 07:06AM

Re: rewrite rules issue

nicocolt April 19, 2015 09:53AM

Re: rewrite rules issue

Francis Daly April 19, 2015 06:52PM

Re: rewrite rules issue

nicocolt April 20, 2015 04:12AM

Re: rewrite rules issue

Francis Daly April 20, 2015 09:06AM

Re: rewrite rules issue

nicocolt April 21, 2015 09:26AM

Re: rewrite rules issue

Francis Daly April 21, 2015 04:50PM

Re: rewrite rules issue

nicocolt April 22, 2015 02:35PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 314
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready