Rewrite all directory URLs with certain exceptions

Cristian Rusu crirus at gmail.com
Wed Nov 28 12:11:01 UTC 2012


Excellent, it worked

I have another urgent matter on a server live we just switched to

I need that links like this:
http://www.example.com/?v=JYH253CT

to be rewritten as http://www.example.com/v.php?dl=JYH253CT


Please help, server is down :(

---------------------------------------------------------------
Cristian Rusu
Web Developement & Electronic Publishing

======
Crilance.com
Crilance.blogspot.com



On Wed, Nov 28, 2012 at 10:30 AM, Maxim Dounin <mdounin at mdounin.ru> wrote:

> 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 at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20121128/db78675a/attachment.html>


More information about the nginx mailing list