htaccess to nginx rewrite

Igor Sysoev is at rambler-co.ru
Wed Jan 21 09:57:19 MSK 2009


On Tue, Jan 20, 2009 at 08:25:06PM +0100, Vahid Mirjamali wrote:

> I've desperately tried to convert my htaccess to nginx but sadly I just
> couldn't figure out how to do it. I really need help badly, I'm willing
> to pay someone 15 dollars to just make my site work again on nginx if
> someone can help me with that.
> 
> Attachments:
> http://www.ruby-forum.com/attachment/3186/htaccess.zip


Here is sample how to convert first several rules:

RewriteCond %{HTTP_HOST} !^www\.pspcrazy\.com
RewriteRule (.*) http://www.pspcrazy.com/$1 [R=301,L]

RewriteRule ^game-browser-([^/]*)-([^/]*)-([0-9]*)-([^/]*)-([^/]*)-([^/]*).html 
index.php?page=BrowseGames&start=$1&cat=$2&nav=$3&genre=$4&esrb=$5&publisher=$6 
[L,NS]
RewriteRule ^image_upload.html index.php?page=Mediaupload [L,NS]
RewriteRule ^image_upload-go.html index.php?page=Mediaupload&action=go [L,NS]
RewriteRule ^image_upload-go-ADD.html index.php?page=Mediaupload&action=go&task=
upload [L,NS]


    server {
        listen  80;
        server_name  www.pspcrazy.com;

        location ~ \.php$ {
             ...
        }

        # RewriteRule ^game-browser-([^/]*)-([^/]*)-([0-9]*)-([^/]*)-([^/]*)-([^/]*).html index.php?page=BrowseGames&start=$1&cat=$2&nav=$3&genre=$4&esrb=$5&publisher=$6 [L,NS]

        location /game-browser- {
            rewrite  ^/game-browser-([^/]*)-([^/]*)-([0-9]*)-([^/]*)-([^/]*)-([^/]*).html
                     /index.php?page=BrowseGames&start=$1&cat=$2&nav=$3&genre=$4&esrb=$5&publisher=$6?
                     last;
        }

        # RewriteRule ^image_upload.html index.php?page=Mediaupload [L,NS]

        location = /image_upload.html {
            rewrite  ^   /index.php?page=Mediaupload   last;
        }

        ...
    }

    # RewriteCond %{HTTP_HOST} !^www\.pspcrazy\.com
    # RewriteRule (.*) http://www.pspcrazy.com/$1 [R=301,L]

    server {
        listen  80   default;
        server_name  _;

        rewrite  ^  http://www.pspcrazy.com$request_uri  permnent;
    }

Other rules should converted as these first ones.


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





More information about the nginx mailing list