Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing the rewrite url in nginx / 1.10.1 is unsuccessful, open the subfolder to download the PHP file #828

Closed
wangqiangcc opened this issue Oct 28, 2016 · 3 comments

Comments

@wangqiangcc
Copy link

vi test.com.conf

server {
listen 80;
server_name *.test.com;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {
    root   /usr/local/www/nginx/test.com;
    index  index.html index.php;
    #rewrite
    location / {
    try_files $uri /index.php?url=$uri&$args;
    }
}


#error_page  404              /404.html;

# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/local/www/nginx-dist;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
#    proxy_pass   http:https://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME /usr/local/www/nginx/test.com$fastcgi_script_name;
    include        fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#    deny  all;
#}

}

/usr/local/sbin/nginx -v

nginx version: nginx/1.10.1

@wangqiangcc
Copy link
Author

wangqiangcc commented Oct 28, 2016

`RewriteEngine On

When using the script within a sub-folder, put this path here, like /mysubfolder/

If your app is in the root of your web folder, then please delete this line or comment it out

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]`

In apache above test Ok, but nginx is unsuccessful

@panique
Copy link
Owner

panique commented Oct 28, 2016

Sorry, no idea what you mean.. Can you please say what exactly the problem is and how to reproduce ? The installer also uses apache, not nginx!

@wangqiangcc
Copy link
Author

Thank you, has been resolved, the description may be unclear, sorry.

    #rewrite
    if (!-e $request_filename){
            rewrite ^/(.+)$ /index.php?url=$1 last;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants