无法在nginx中隐藏index.php以进行socialengine重写
我不熟悉nginx重写,但我正在尝试在nginx上运行socialengine。除了domain.com/index.php或domain.com之外,我有以下重写规则似乎在任何地方都可以使用。这些规则似乎适用于所有其他链接(不在/install/path中,我已经知道这需要另一组重写规则) 我的规则遗漏了什么无法在nginx中隐藏index.php以进行socialengine重写,nginx,url-rewriting,socialengine,Nginx,Url Rewriting,Socialengine,我不熟悉nginx重写,但我正在尝试在nginx上运行socialengine。除了domain.com/index.php或domain.com之外,我有以下重写规则似乎在任何地方都可以使用。这些规则似乎适用于所有其他链接(不在/install/path中,我已经知道这需要另一组重写规则) 我的规则遗漏了什么 server { listen 8080; server_name domain.com www.domain.com; root /home/us
server {
listen 8080;
server_name domain.com www.domain.com;
root /home/user/public_html;
index index.php;
#charset koi8-r;
#access_log logs/host.access.log main;
# BLOCKS ACCESS TO . FILES (.svn, .htaccess, ...)
location ~ /\. {
deny all;
}
location / {
try_files $uri $uri/ @seRules;
}
location @seRules {
rewrite /index\.php /index.php?rewrite=2;
rewrite ^(.*)$ /index.php?rewrite=1;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_pass_request_body off;
client_body_in_file_only clean;
fastcgi_param REQUEST_BODY_FILE $request_body_file;
}
error_page 404 /404.html;
location = /404.html {
root /home/user/public_html;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /home/user/public_html;
}
}
只需在conf中包含以下内容。这也将隐藏index.php location~index.php{
root /home/user/public_html;
rewrite .* /index.php?rewrite=1 break;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/user/public_html$fastcgi_script_name;
include fastcgi_params;
fastcgi_param DOCUMENT_ROOT /home/user/public_html;
fastcgi_pass_request_body off;
client_body_in_file_only clean;
fastcgi_param REQUEST_BODY_FILE $request_body_file;
}
location /
{
if (!-e $request_filename) {rewrite ^(.*)$ /index.php?rewrite=1 last;}
# avoid redirect / -> /index.php
if ($request_uri = '/') {rewrite ^(.*)$ /index.php?rewrite=1 last;}
}