Rewrite on Nginx

admin4170

Member
Aug 8, 2014
30
0
6
Hello
I use Nginx as webserver
I use v3.5 currently and it works fine
Code:
rewrite ^(.*).html$ $1.php break;
 
 if ($request_uri ~ "^(.+)\~s$")
 {
        rewrite ^/(.*) /stats.php?u=$1
        break;
 }
 if ($request_uri ~ "^(.+)\~d\?(.+)$")
 {
        rewrite ^/(.*) /delete_file.php?u=$1
        break;
 }
 if ($request_uri ~ "^(.+)\~i$")
 {
        rewrite ^/(.*) /share_file.php?u=$1
        break;
 }
 if ($request_uri ~ "^(.+)\~f$")
 {
        rewrite ^/(.*) /view_folder.php?u=$1
        break;
 }
 if (-f $request_filename) { break;}
 if (-d $request_filename) { break;}
 
 rewrite ^/(.+)$ /file_download.php?u=$1;
Try to upgrade V4.0.1 but Rewrite is not working
Please help the code I must change.
Thank you
 

admin4170

Member
Aug 8, 2014
30
0
6
Hello
Not any support?
I use php-fpm55/nginx not revese proxy
I tried as ___NGINX_RULES.txt but it didn't work

I tried:
Code:
if (!-f $request_filename){
	set $rule_0 1$rule_0;
}
if (!-d $request_filename){
	set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
	rewrite ^/(.*)$ /index.php?_page_url=$1;
}
It works but problem is:
http://domain.com/index.php --> working
http://domain.com ---> not working
(remember: index.html index.php index.htm is ok if delete yetishare script)

Please help
 

adam

Administrator
Staff member
Dec 5, 2009
2,046
108
63
Hi,

We don't always monitor these forums for support issues as they're community based so you're based raising a ticket in future. You're not using the correct nginx rules however, have a look in the root of the source code for "___NGINX_RULES.txt" to see the rules (the latest v4.0.1 code).

I'd also recommend using just nginx over proxy mode. Proxy mode is a lot harder to manage and configure.

Thanks,
Adam.
 

admin4170

Member
Aug 8, 2014
30
0
6
My server use Nginx + php-fpm55
File ___NGINX_RULES.txt is effect for Nginx + PHP Reverse proxy only
I asked my friend and problem was resolved.
This is code, you can add to ___NGINX_RULES.txt for clients who use Nginx + php-fpm55

Code:
if (!-f $request_filename){
	set $rule_0 1$rule_0;
}
if (!-d $request_filename){
	set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
	rewrite ^/(.*)$ /index.php?_page_url=$1;
}
if ($http_host ~ "^(www.)?domain.com$"){
	set $rule_0 1$rule_0;
}
if ($rule_0 = "1"){
	rewrite ^/$ http://domain.com/index.html permanent;
}