【发布时间】:2015-02-22 23:44:40
【问题描述】:
我开发了我的 CI 应用程序并在超过 4 个 Apache 服务器上对其进行了测试,它运行良好。但是在我将它上传到 Nginx 的新服务器之后,它的 url 有问题。我用谷歌搜索了很多,几乎做了每件事,但没有结果。现在问题来了:
由于项目结构和规模,我需要每个网址都像这样:
http://example.com/myappname/controller/action 例如:http://example.com/myappname/auth/login
但它不起作用。起作用的是: http://example.com/myappname/index.php?/auth/login 这不是我想要的。
nginx的配置是:
server {
listen 80;
listen [::]:80;
root /var/nginx/www/mydomain.com/www;
index index.php index.html index.htm;
server_name mydomain.com www.mydomain.com;
location / {
try_files $uri $uri/ /index.php?/$request_uri;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
# With php5-fpm:
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
location ~* \.(png|jpg|jpeg|gif|ico|ttf|woff)(\?ver=[0-9.]+)?$ {
expires 1w;
}
location ~* \.(css|js|html)(\?ver=[0-9.]+)?$ {
expires 1w;
}
}
【问题讨论】:
标签: php codeigniter url nginx