2016-04-13 17 views
3

Codeiniter whith nginx sunucusunu kullanarak index.php? kaldırmaya çalışıyorum, ancak işe yaramıyor.Codeigniter (nginx) 'den index.php nasıl kaldırılır

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

sonucu: Ben, https://www.nginx.com/resources/wiki/start/topics/recipes/codeigniter/ Aslında nginx web sitesinin resmi çözüm uğraş varsayılan dosyasında i şu kod var: Aşağıdaki

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

} 

Ve config.php dosyasını olduğunu herhangi bir istek 502 Bad Gateway'dir.

cevap

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

}

ve yapılandırma dosyası

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

Teşekkür Muhammed, ama önce bu çözümü uygulamaya çalışıyorum ve işe gelmiyor.Fark. Belki de nginx resmi çözümünü uyguladığımı açıklığa kavuşturmalıyım – xylander