Rewrite URL to only show value of $_GET argument

Andrew Martin andrew.s.martin at gmail.com
Wed Sep 11 02:07:46 UTC 2013


Francis,


On Tue, Sep 10, 2013 at 11:46 AM, Francis Daly <francis at daoine.org> wrote:

> On Mon, Sep 09, 2013 at 08:23:36AM -0500, Andrew Martin wrote:
>
> Hi there,
>
> > If I use this line:
> > rewrite ^/index\.php(.*)$ http://mysite.com/$arg_title? redirect;
> >
> > /index.php?title=my_test_page redirects to /my_test_page
>
> That's what you asked for initially; I'd probably spell it as
>
>   location = /index.php {
>     return 302 http://mysite.com/$arg_title;
>   }
>
> to make it clear what exactly is happening, and which might point out
> the parts you didn't specify:
>
> what should happen if I ask for any of
>
>   /index.php?something=else
>   /index.php?title=my_test_page&something=other
>   /index.php
>
> ? With the above code, the second will possibly redirect the way you want,
> and the others probably won't.
>
Would it be possible to only redirect if the title $_GET variable is
present?

>
> Also, what should happen when I ask for
>
>   /my_test_page
>
> ? I will do that immediately after you redirect me there.
>
> If you can describe the complete behaviour you want, the nginx
> configuration needed to achieve it may become clear.
>
Thanks for clarifying this. The complete behavior I'm looking for is just to
create SEF URLs for pages on the site by hiding the index.php?title= part
of the URL. Thus, visiting /my_test_page in your browser would internally
load the index.php?title=my_test_page URL but display the SEF URL to
the user. How can I achieve this behavior?

Thanks,

Andrew

>
>         f
> --
> Francis Daly        francis at daoine.org
>
> _______________________________________________
> 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/20130910/6b920f73/attachment.html>


More information about the nginx mailing list