Welcome! Log In Create A New Profile

Advanced

Re: Rewrite all directory URLs with certain exceptions

Maxim Dounin
November 28, 2012 03:32AM
Hello!

On Wed, Nov 28, 2012 at 10:04:58AM +0200, Cristian Rusu wrote:

> Hello
>
> I have urls like example.com/123
> I need them rewritten to example.com/?v=123
>
> However, I want to skip certain directories from rewrite
> eg.
> example.com/status
> example.com/admin
>
> right now I have this:
>
> if (!-e $request_filename){
> rewrite ^/([A-Za-z0-9-]+)/?$ http://www.example.com/v.php?dl=$1redirect;
> }
>
> Problem is that all urls are rewritten.. how do I put some exceptions?

I would recommend using location matching to differentiate URIs
which should be handled differently. E.g.

location / {
# you may want to use try_files here instead
if (...) {
rewrite ...
}
...
}

location /status {
...
}

location /admin {
...
}

See http://nginx.org/r/location for more information.

--
Maxim Dounin
http://nginx.com/support.html

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

Rewrite all directory URLs with certain exceptions

crirus November 28, 2012 03:06AM

Re: Rewrite all directory URLs with certain exceptions

Edho Arief November 28, 2012 03:08AM

Re: Rewrite all directory URLs with certain exceptions

Maxim Dounin November 28, 2012 03:32AM

Re: Rewrite all directory URLs with certain exceptions

crirus November 28, 2012 07:12AM

Re: Rewrite all directory URLs with certain exceptions

Edho Arief November 28, 2012 07:26AM

Re: Rewrite all directory URLs with certain exceptions

crirus November 28, 2012 07:34AM

Re: Rewrite all directory URLs with certain exceptions

Antonio P.P. Almeida November 28, 2012 08:00AM

Re: Rewrite all directory URLs with certain exceptions

crirus November 28, 2012 08:06AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 151
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