htaccess to nginx rewrite

Igor Sysoev is at rambler-co.ru
Wed Jan 28 13:28:37 MSK 2009


On Tue, Jan 27, 2009 at 10:12:45PM +0100, Vahid Mirjamali wrote:

> Vahid Mirjamali wrote:
> > I did all the changed but it still failed to make it work, reattached 
> > the new htaccess converts.
> > 
> > Any Ideas?
> 
> And attached here is the full config for just that domain.
> 
> Attachments:
> http://www.ruby-forum.com/attachment/3214/fulthing.txt

Looking at the configuration, I'm starting to understand Python's author,
when he had decided to force indention.

This

------------------
server
{
listen 192.168.93.208:80;
server_name pspcrazy.com www.pspcrazy.com;

if ($host != 'www.pspcrazy.com' ) {
rewrite ^/(.*)$ http://www.pspcrazy.com/$1 permanent;
rewrite  ^  http://www.pspcrazy.com$request_uri?  permanent;
}

...
------------------

should be rewritten as two servers (as I have already told):

------------------
server {
    listen 192.168.93.208:80;
    server_name pspcrazy.com;

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

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

    ...
------------------

This

------------------
location ~* ^/forums/((admincp/images|clientscript|cpstyles|images)/.*)$
{
root /home/user/pspcrazy.com/httpdocs;

if (-f $request_filename) {
expires 30d;
break;
}

if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php last;
}

}
------------------

should be rewritten as:

------------------
location ~* ^/forums/((admincp/images|clientscript|cpstyles|images)/.*)$ {
    root /home/user/pspcrazy.com/httpdocs;
    expires 30d;

    error_page  404  = @php;
}

location @php {
    root /home/user/pspcrazy.com/httpdocs;
    fastcgi_pass 127.0.0.1:9000;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root/index.php;
    fastcgi_param PATH_TRANSLATED $document_root/index.php;
}

------------------

etc. Do not use "if"s at all.


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





More information about the nginx mailing list