Rewrite URL to only show value of $_GET argument

Andrew Martin andrew.s.martin at gmail.com
Mon Sep 9 13:23:36 UTC 2013


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

This is the URL I am looking for, but it still results in a 404, with this
displayed in the log:
[error] 16077#0: *156649 FastCGI sent in stderr: "Primary script unknown"
while reading response header from upstream, client xxx.xxx.xxx.xxx,
server: mysite.com, request: "GET /my_test_page HTTP/1.1", upstream:
"fastcgi://127.0.0.1:9000", host: "mysite.com"

Thanks,

Andrew


On Mon, Sep 9, 2013 at 8:05 AM, wishmaster <artemrts at ukr.net> wrote:

>
>
>  --- Original message ---
> From: "Andrew Martin" <andrew.s.martin at gmail.com>
> Date: 9 September 2013, 15:53:01
>
>
> > Thanks for the suggestions. I was not able to get $arg_title to work.
> Here is the relevant section of my nginx config:        server_name
> mysite.com;
> >
> >
> >
> >
> > try_files $uri $uri/ index.php;
> >
> >
> > location / {
> > rewrite ^/index\.php?title=(.*)$ http://mysite.com/$arg_title redirect;
> >
>   May be something like this :
>   rewrite ^/index\.php.* http://mysite.com/$arg_title redirect;
> I think nginx "know" about all arguments in your request, therefore simple
> specify needed argument's name in the second part of rewrite rule.
>
>
>
> _______________________________________________
> 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/20130909/1b668435/attachment.html>


More information about the nginx mailing list