vhost conf for typo3

Igor Sysoev is at rambler-co.ru
Wed Mar 25 17:57:44 MSK 2009


On Wed, Mar 25, 2009 at 11:07:10AM +0100, hostis.pl wrote:

> Hi all,
> 
> i have little problem with setting rewrite rules for directories like
> typo3. I can access to typo3 admin panel. Site works almost perfectly
> with one exception.
> When i pass url like http://domain/typo3/sysext/noborder.html (this file
> dosen't exist) it should send back 404 error.
> But i get rendered main page with html content and without any styles,
> images, etc.
> 
> i try to do it by my own but it dosen't work good.
> 
> here is .htaccess rewrite rules:
> 
> # Stop rewrite processing if we are in the typo3/ directory
> # For httpd.conf, use this line instead of the next one:
> RewriteRule
> ^(typo3|t3lib|tslib|fileadmin|typo3conf|typo3temp|uploads|showpic\.php|favicon\.ico)/
> - [L]
> 
> # Redirect http://mysite/typo3 to http://mysite/typo3/index_re.php
> # and stop the rewrite processing
> # For httpd.conf, use this line instead of the next one:
> RewriteRule ^typo3$ typo3/index_re.php [L]
> 
> My vhost config:
> 
> # VirtualHost F1
> server {
>   listen   80;
>   server_name  domain.pl;
> 
>   root   /var/www/domain.pl;
>   index  index.php;
> 
>   charset utf-8;
> 
>   access_log  /var/log/nginx/domain.pl.access.log;
>   error_log   /var/log/nginx/domain.pl.error_log info;
> 
>   rewrite rss.xml /index.php?id=221&type=100 last;
>   rewrite sitemap.xml /sitemap.xml;
>   rewrite ^typo3$ /typo3/index_re.php last;
>   rewrite
> ^(typo3|t3lib|tslib|fileadmin|typo3conf|typo3temp|uploads|showpic\.php|favicon\.ico)/
> last;
> 
>   location / {
>     if (!-e $request_filename) {
>       rewrite ^(.*) /index.php last;
>     }
>   }
> 
>   location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|flv|swf|txt)$ {
>     access_log  off;
>     expires     30d;
>   }
> 
>   location ~ \.php$ {
>     fastcgi_pass      127.0.0.1:9000;
>     fastcgi_index     index.php;
> 
>     fastcgi_param     SCRIPT_FILENAME 
>     /var/www/domain.pl/$fastcgi_script_name;
>     include           fastcgi_params;
>   }
> }

First, nginx uses leading slash in URI:

   rewrite ^typo3$  /typo3/index_re.php last;
   rewrite ^/typo3$ /typo3/index_re.php last;

However, your configuration should be rewritten

    location / {
        error_page  404 = /index.php;
    }

    location = /typo3 {
        fastcgi_pass   127.0.0.1:9000;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  /var/www/domain.pl/typo3/index_re.php;
        fastcgi_param  QUERY_STRING     $query_string;
    }

    location = /rss.xml {
        fastcgi_pass   127.0.0.1:9000;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  /var/www/domain.pl/index.php;
        fastcgi_param  QUERY_STRING     id=221&type=100;
    }

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME /var/www/domain.pl/$fastcgi_script_name;
        fastcgi_param  QUERY_STRING     $query_string;
    }

    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|flv|swf|txt)$ {
        access_log     off;
        expires        30d;
    }

Also, you need to remove QUERY_STRING from fastcgi_params file.


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





More information about the nginx mailing list