htaccess to nginx rewrite

Igor Sysoev is at rambler-co.ru
Thu Jan 22 10:39:55 MSK 2009


On Thu, Jan 22, 2009 at 10:33:08AM +0300, Igor Sysoev wrote:

> On Thu, Jan 22, 2009 at 08:11:01AM +0100, Vahid Mirjamali wrote:
> 
> > Igor Sysoev wrote:
> > 
> > I've attached a new version of this, any mistakes that you notice off 
> > the bat, as i'd like to make sure it's ok before going live with it. If 
> > not let me know what's still wrong and some more examples.
> > 
> > Attachments:
> > http://www.ruby-forum.com/attachment/3193/newrewrite.txt
> 
> 1) You do not need this at all:
> 
> RewriteEngine On 
> 
> RewriteCond %{HTTP_HOST} !^www\.pspcrazy\.com
> RewriteRule (.*) http://www.pspcrazy.com/$1 [R=301,L]
> 
> 2) In this type of rewrites with $1, $2, etc:
> 
> location = /vote-([0-9]*).html {

Yet more, any regex:

- location = /vote-([0-9]*).html {
+ location ~ /vote-([0-9]*).html {

"=" means exact match.

>             rewrite  ^   /index.php?page=Vote&id=$1  last;
>         }
> 
> -           rewrite  ^   /index.php?page=Vote&id=$1  last;
> +           rewrite  ^/vote-([0-9]*).html   /index.php?page=Vote&id=$1  last;
> 
> 
> 3) In this type of rewrites:
> 
> location = /polls.html {
>             rewrite  ^   index.php?page=Polls last;
>         }
> 
> -           rewrite  ^   index.php?page=Polls last;
> +           rewrite  ^   /index.php?page=Polls last;
> 
> 4) You need to place these rules inside one server and then add 
> rewrite for www.pspcrazy.com:
> 
> server {
>     server_name  www.pspcrazy.com;
> 
>     location /game-browser- {
>         ...
>     }
> 
>     ...
> 
>     location = /rss-articles.xml {
>          rewrite  ^ rss-articles.php last;
>     }
> 
>     # do not forget about PHP handler:
>     location ~ \.php$ {
>          ...
>     }
> }
> 
> server {
>      listen  80   default;
>      server_name  _;
> 
>      rewrite  ^  http://www.pspcrazy.com$request_uri?  permanent;
> }
> 
> 
> 
> 
> 
> -- 
> Igor Sysoev
> http://sysoev.ru/en/

-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list