Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I just changed to NGINX from Apache and I am using Zencart with Ultimate SEO for friendly urls I have tried to convert my .htaccess rules for NGINX but I get "No Input file specified" or a 404 error. My original .htaccess is as follows:

     ErrorDocument 404 /404.html

     Options +FollowSymLinks
     RewriteEngine On

     # From Ultimate SEO URLs
     RewriteRule ^(.*)-p-(.*).html$ index\.php?main_page=product_info&products_id=$2&%{QUERY_STRING} [L]
     RewriteRule ^(.*)-c-(.*).html$ index\.php?main_page=index&cPath=$2&%{QUERY_STRING} [L]
     RewriteRule ^(.*)-m-([0-9]+).html$ index\.php?main_page=index&manufacturers_id=$2&%{QUERY_STRING} [L]
     RewriteRule ^(.*)-pi-([0-9]+).html$ index\.php?main_page=popup_image&pID=$2&%{QUERY_STRING} [L]
     RewriteRule ^(.*)-pr-([0-9]+).html$ index\.php?main_page=product_reviews&products_id=$2&%{QUERY_STRING} [L]
     RewriteRule ^(.*)-pri-([0-9]+).html$ index\.php?main_page=product_reviews_info&products_id=$2&%{QUERY_STRING} [L]
     RewriteRule ^(.*)-ezp-([0-9]+).html$ index\.php?main_page=page&id=$2&%{QUERY_STRING} [L]

     # All other pages
     # Don't rewrite real files or directories
     RewriteCond %{REQUEST_FILENAME} !-f [NC] 
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule ^(.*).html$ index\.php?main_page=$1&%{QUERY_STRING} [L]

And this us what I have added in to the virtual.conf in NGINX

     rewrite ^/(.*)-p-(.*).html$ /index\.php?main_page=product_info&products_id=$2&$args last;
     rewrite ^/(.*)-c-(.*).html$ /index\.php?main_page=index&cPath=$2&$args last;
     rewrite ^/(.*)-m-([0-9]+).html$ /index\.php?main_page=index&manufacturers_id=$2&$args last;
     rewrite ^/(.*)-pi-([0-9]+).html$ /index\.php?main_page=popup_image&pID=$2&$args last;
     rewrite ^/(.*)-pr-([0-9]+).html$ /index\.php?main_page=product_reviews&products_id=$2&$args last;
     rewrite ^/(.*)-pri-([0-9]+).html$ /index\.php?main_page=product_reviews_info&products_id=$2&$args last;
     rewrite ^/(.*)-ezp-([0-9]+).html$ /index\.php?main_page=page&id=$2&$args last;
     if (!-f $request_filename){
     set $rule_7 1$rule_7;
    if (!-d $request_filename){
    set $rule_7 2$rule_7;
    if ($rule_7 = "21"){
    rewrite ^/(.*).html$ /index\.php?main_page=$1&$args last;


Any ideas what I have done wrong?



merged by Mark Henderson Aug 1 '11 at 8:06

This question was merged with apache mod-rewrite to nginx rewrite because it is an exact duplicate of that question.

migrated from Aug 1 '11 at 5:02

This question came from our site for professional and enthusiast programmers.