Serve (almost) all index.php request by /index.php

Is it possible to have all index.php request being processed by
I have a Joomla+VirtueMart website I recently moved from apache to nginx
(can’t compare performances, nginx is ages faster and has far far less
impact on the server itself! Congratulations!!)-
With the old setup urls like /something/index.php were forwarded to file
/index.php. This is apache’s htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)file_id=([^&])(&|$)
RewriteCond %{REQUEST_URI} !/oldfiles
RewriteRule .
RewriteCond %{QUERY_STRING} base64_encode[^(]([^)]) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]s)+cript.(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI}
/component/|(/[^.]|.(php|html?|feed|pdf|vcf|raw))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/server-status
RewriteRule .
index.php [L]

Now with nginx it gives 404 not found.
Is it possible to do such config? all request requiring index.php and
when the file doesn’t exist on disk it should be served by /index.php.


This is my current config:
server {
listen 81 default_server;

    root   /var/www/nginx-default;
    index  index.php index.html index.htm;
    client_max_body_size 3M;

    # Make site accessible from http://localhost/
    server_name localhost;

    location / {
            try_files $uri $uri/ /index.php?$args;

    # deny running scripts inside writable directories
    location ~* 

/(images|cache|media|logs|tmp)/.*.(php|pl|py|jsp|asp|sh|cgi)$ {
return 403;
error_page 403 /403_error.html;

    location ~ .php$ {
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_index  index.php;
            fastcgi_param SCRIPT_FILENAME 

include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
location ~ /.ht {
deny all;
# caching of files
location ~* .(ico|pdf|flv)$ {
expires 30d;

    location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
            expires 14d;


Lorenzo Milesi - [email protected]

YetOpen S.r.l. -