Welcome! Log In Create A New Profile

Advanced

Re: Re: rewrite problem

Maxim Dounin
September 04, 2012 01:22PM
Hello!

On Tue, Sep 04, 2012 at 08:05:46PM +0800, sosogh wrote:

> Thank you very much .It works.
> But there is another problem.
>
>
> I want
> http://www.mysite.com/bbs/
> to
> http://www.mysite.com/
>
> why the following conf does not work?
> rewrite ^/bbs/$ /index.php last;

Define "does not work". If in doubt, try looking into error log,
probably with

rewrite_log on;

added to your config (and error_log set to at least "notice"
level), it should give you enough information to find out what
goes wrong.

> I want
> http://www.mysite.com/bbs/thread-4270-1-2.html
> to
> http://www.mysite.com/forum.php?mod=viewthread&tid=4270&extra=1&page=2
>
>
> why the following conf does not work?
> location ~* ^/bbs/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ {
> rewrite ^/bbs/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /forum.php?mod=viewthread&tid=$1&extra=$2&page=$3 break;
> }

This will likely result in /forum.php source code being returned as
you use "break" and doesn't handle php in the location in
question. See http://nginx.org/r/rewrite for details.

Maxim Dounin

>
>
> Thank you !
>
>
>
>
>
>
>
> Hello!
> On Tue, Sep 04, 2012 at 10:59:40AM +0800, sosogh wrote:
> > HI list
> > I want to redirect
> > http://www.mysite.com/bbs/viewthread.php?tid=8123&extra=
> > to
> > http://www.mysite.com/forum.php?mod=viewthread&tid=8123
> >
> > This is what I place in the "server" block in the nginx.conf
> > rewrite ^/bbs/viewthread.php?tid=([0-9]+).*$ /forum.php?mod=viewthread&tid=$1 last;
> >
> > but when visit http://www.mysite.com/bbs/viewthread.php?tid=8123&extra=.
> > It shows 404 error.
> >
> > Could anyone point me out what is wrong?
> > Thank you!
> The rewrite in question won't match anything as rewrite work with
> URI without arguments. Use something like this instead:
> location = /bbs/viewthread.php {
> if ($arg_tid ~ ^[0-9]+$) {
> rewrite ^ /forum.php?mod=viewthread&tid=$arg_tid? last;
> }
> ...
> }
> Some more details may be found here:
> http://nginx.org/r/location
> http://nginx.org/r/rewrite
> http://nginx.org/r/if
> Maxim Dounin
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

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

rewrite problem

sosogh September 03, 2012 11:00PM

Re: rewrite problem

Bertrand Caplet September 04, 2012 02:08AM

Re: rewrite problem

Christopher Meng September 04, 2012 02:18AM

Re: rewrite problem

Maxim Dounin September 04, 2012 04:00AM

Re: Re: rewrite problem

sosogh September 04, 2012 08:08AM

Re: Re: rewrite problem

Maxim Dounin September 04, 2012 01:22PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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