我在 nginx 上有一个 codeigniter php 应用程序。它在 Apache 上按预期运行,但移至 nginx 后,我注意到 index.php 已自动从我的所有链接的 URL 中删除。事实上,当我尝试使用 index.php 时,它不会转到所需的 URL,而是重定向到我的默认控制器。
下面是我的 nginx.conf 文件的副本。
server{
listen 80;
server_name mydomainname.com;
root /var/www/domain/current;
# index index.php;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log main;
location / {
# Check if a file or directory index file exists, else route it to index.php.
try_files $uri $uri/ /index.php ;
}
location ~* \.php {
fastcgi_pass backend;
include fastcgi.conf;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_read_timeout 500;
#fastcgi_param SCRIPT_FILENAME $document_root/index.php;
add_header Expires "Thu, 01 Jan 1970 00:00:01 GMT";
add_header Cache-Control "no-cache, no-store, private, proxy-revalidate, must-revalidate, post-check=0, pre-check=0";
add_header Pragma no-cache;
add_header X-Served-By $hostname;
}
location ~* ^.+\.(css|js)$ {
expires 7d;
add_header Pragma public;
add_header Cache-Control "public";
}
# set expiration of assets to MAX for caching
location ~* \.(ico|gif|jpe?g|png)(\?[0-9]+)?$ {
expires max;
log_not_found on;
}
}
我需要将我的 URL 与 index.php 一起使用——请帮忙。