2014-02-25 35 views
2

我是新來的nginx重寫,但我想在nginx上運行socialengine。除了domain.com/index.php或domain.com之外,我有以下重寫規則似乎可以在任何地方使用。規則似乎適用於所有其他鏈接(不在我已經知道的/ install /路徑中將需要另一組重寫規則)。不能隱藏在nginx的index.php爲socialengine重寫

我從規則中遺漏了什麼?

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; 
    } 
} 

回答

0

只需在conf中包含以下內容。這將隱藏的index.php太..

位置〜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; 
} 
0
location/
{ 
if (!-e $request_filename) {rewrite ^(.*)$ /index.php?rewrite=1 last;} 

# avoid redirect/-> /index.php 
if ($request_uri = '/') {rewrite ^(.*)$ /index.php?rewrite=1 last;} 
}