Welcome! Log In Create A New Profile

Advanced

a tool for converting htaccess files.. and a question

Posted by ura 
ura
a tool for converting htaccess files.. and a question
January 14, 2014 03:43PM
i just found this site which has a converter for htaccess files - to create nginx files from them: http://winginx.com/htaccess

i use the elgg framework (www.elgg.org) and i ran the htaccess file that comes with the elgg framework through this tool and the nginx config that was produced is running fine in my local development server - however, on my live server i am served a file for download instead of html pages when i use this same new config.

the problematic lines are - in the original htaccess:

# Everything else that isn't a file gets routed through the page handler
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9\_\-]+)$ engine/handlers/page_handler.php?handler=$1 [QSA,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9\_\-]+)\/(.*)$ engine/handlers/page_handler.php?handler=$1&page=$2 [QSA,L]

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

and they are converted to:

location / {
if (!-e $request_filename){
rewrite ^/([A-Za-z0-9\_\-]+)$ /engine/handlers/page_handler.php?handler=$1 break;
}
if (!-e $request_filename){
rewrite ^/([A-Za-z0-9\_\-]+)\/(.*)$ /engine/handlers/page_handler.php?handler=$1&page=$2 break;
}
}

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

and the nginx config i was already using (which i did not create) handles this part of the config using:

if (!-d $request_filename){
set $rule_11 1$rule_11;
}
if (!-f $request_filename){
set $rule_11 2$rule_11;
}
if ($rule_11 = "21"){
rewrite ^/([A-Za-z0-9\_\-]+)$ /engine/handlers/page_handler.php?handler=$1;
}
if (!-d $request_filename){
set $rule_12 1$rule_12;
}
if (!-f $request_filename){
set $rule_12 2$rule_12;
}
if ($rule_12 = "21"){
rewrite ^/([A-Za-z0-9\_\-]+)\/(.*)$ /engine/handlers/page_handler.php?handler=$1&page=$2;
}

-------

in my research into the nginx manual/docs/wiki i concluded that try_files should be used to replace these various versions..
so far i have not had success with try_files either and testing is tricky because this is only occurring on my production server and i am unclear on why that is.

any tips welcomed! thanks
ura
Re: a tool for converting htaccess files.. and a question
January 14, 2014 06:20PM
ah, oops.. i had forgotten to reload nginx on my development pc after changing the config..
so now the config doesn't work on both pcs!
a step towards comprehension at least.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 118
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready