Htaccess to nginx, real nightmare - Any advice?

Hello

I’m using Nginx from 3 weeks for wordpress and scripts like
phplinkdirectory. Unfortunately i’m still noob converting htaccess rules
to
nginx and sometimes a simple conversion is a real nightmare. I cannot
solve
this conversion from htaccess to nginx and i hope to find someone to
point
me to the right direction.

htaccess code:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^(.+)~s$
RewriteRule ^(.) stats.php?u=$1 [L]
RewriteCond %{REQUEST_URI} ^(.+)~d$
RewriteRule ^(.
) delete_file.php?u=$1 [QSA,L]
RewriteCond %{REQUEST_URI} ^(.+)~i$
RewriteRule ^(.) share_file.php?u=$1 [QSA,L]
RewriteCond %{REQUEST_URI} ^(.+)~f$
RewriteRule ^(.
) view_folder.php?f=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !.html$
RewriteRule ^(.) file_download.php?u=$1 [QSA,L]
RewriteRule ^(.
).html$ $1.php [QSA,L]

Nginx code (i’m using it on a subdomain, my server is centos 6.3 +
virtualmin + nginx + fastcgi. Server is already configured and 100%
working.):

server {
server_name download.mysite.com www.download.mysite.com;
listen 173.245.7.94;
root /home/mysite/domains/download.mysite.com/public_html;
access_log /var/log/virtualmin/download.mysite.com_access_log;
error_log /var/log/virtualmin/download.mysite.com_error_log;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME
/home/mysite/domains/download.mysite.com/public_html$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT
/home/mysite/domains/download.mysite.com/public_html;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
location ~ .php$ {
try_files $uri =404;
fastcgi_pass localhost:9003;
}
location / {
index index.html index.htm index.php;
if (!-f $request_uri) { rewrite ^/([^/]+)~s
/stats.php?u=$1 last;}
if (!-f $request_uri) { rewrite ^/([^/]+)~d
/delete_file.php?u=$1 last;}
if (!-f $request_uri) { rewrite ^/([^/]+)~i
/share_file.php?u=$1 last;}
if (!-f $request_uri) { rewrite ^/([^/]+)~f
/view_folder.php?u=$1 last;}
if (!-f $request_filename) { rewrite ^/([^/]+)
/file_download.php?u=$1 last;}
#rewrite html to php
rewrite ^(.*).html$ $1.php break;
}

I have other domains (wordpress, phplinkdirectory) and they work well
with
nginx. The only problem is converting this subdomain htaccess to nginx.
Code
seems correct (virtualmin accept it and doesn’t return errors) but in
practise this code is completely incorrect. rewrite is 1/2 working, i’m
having a lot of loops and a lot of php pages (rewrite php to html)
aren’t
processed (i see only the source or the browser download my PHP page
instead
of rendering it.)

Any advice ? Thanks in advance.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,234820,234820#msg-234820

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs