Welcome! Log In Create A New Profile

Advanced

How to convert this code to Nginx?

Posted by niceandcoolman 
How to convert this code to Nginx?
April 07, 2012 04:20AM
I just want to convert this following code to Nginx.
Kindly suggest me.
Thank you very much.

=========================================

if($ip)
{
open(FILE,">$c->{htdocs_dir}/$rand/.htaccess");
$ip=~s/\./\\./g;
$file_name=~s/\s/_/g;
print FILE qq[RewriteEngine on\nRewriteCond %{REMOTE_ADDR} !^$ip\nRewriteRule ^.*\$ "$c->{site_url}/404.html?$c->{site_url}/$f->{file_code1}/$file_name.html"];
close FILE;
}

========================================
Re: How to convert this code to Nginx?
April 25, 2012 07:02AM
You're mixing a script code with apache rewritecond expressions, in essence making a dynamic rule at runtime. I'm missing the purpose of the $ip checks in setup as well. Nginx doesn't support .htaccess file either.

You should look into using : $remote_addr

See :

http://wiki.nginx.org/HttpCoreModule



Edited 1 time(s). Last edit at 04/25/2012 07:03AM by gplv2.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 167
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready