3
我試圖刪除index.php?
使用Codeigniter與nginx服務器,但它不工作。我tryed nginx的網站的官方的解決辦法https://www.nginx.com/resources/wiki/start/topics/recipes/codeigniter/ 其實,在默認的文件,我有以下代碼:如何從Codeigniter(nginx)中刪除index.php
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;
}
}
}
而且config.php文件如下:
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
的結果任何請求都是502 Bad Gateway。
感謝穆罕默德,但我嘗試之前,實施這一解決方案,它doesn't工作。也許我必須澄清一下,我實現了nginx官方解決方案 – xylander