2016-04-13 22 views
3

Ich versuche, die index.php? mithilfe von Codeigniter mit Nginx-Server zu entfernen, aber es funktioniert nicht. Ich habe versucht die offizielle Lösung von nginx Website https://www.nginx.com/resources/wiki/start/topics/recipes/codeigniter/ Eigentlich in der Standarddatei, ich habe den folgenden Code:So entfernen Sie index.php von Codeigniter (nginx)

server { 
     listen 99 default_server; 
     listen [::]:99 default_server ipv6only=on; 

     root /var/www; 
     index index.html index.htm index.php; 
     autoindex on; 
     # Make site accessible from http://localhost/ 
     server_name localhost; 



     index index.php; 
location/{ 
    set $page_to_view "/index.php"; 
    try_files $uri $uri/ @rewrites; 
    root /var/www/site; 
    index index.php index.html index.htm; 
} 

location ~ \.php$ { 
    include /etc/nginx/fastcgi_params; 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME /var/www/site$page_to_view; 
} 

# rewrites 
location @rewrites { 
    if ($uri ~* ^/([a-z]+)$) { 
     set $page_to_view "/$1.php"; 
     rewrite ^/([a-z]+)$ /$1.php last; 
    } 
} 

} 

Und die config.php ist die folgende:

$config['base_url'] = ''; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'REQUEST_URI'; 

Das Ergebnis Jede Anfrage ist 502 Bad Gateway.

Antwort

0
server { 
    listen  80; 
    server_name localhost; 
    root /var/www/html/ci; 
    autoindex on; 
    index index.php; 

    location/{ 

     try_files $uri $uri/ /index.php; 

     location = /index.php { 

      fastcgi_pass 127.0.0.1:6969; 
      fastcgi_param SCRIPT_FILENAME /var/www/html/ci$fastcgi_script_name; 
      include  fastcgi_params; 
     } 
    } 

    location ~ \.php$ { 
     return 444; 
    } 

}

und Konfigurationsdatei

$config['base_url'] = ""; 
    $config['index_page']  = ""; 
    $config['uri_protocol']  = "AUTO"; 
+0

Dank Muhammad, aber ich versuche, diese Lösung zu implementieren, bevor und es nicht funktioniert. Vielleicht muss ich klarstellen, dass ich die offizielle nginx-Lösung implementiere – xylander

Verwandte Themen