本文介绍了如何在Ubuntu,nGinx和Codeigniter中启用URL重写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在服务器上设置了ubuntu,php5.6,nGinx,并且在配置的网站下部署了一些项目.我需要在目录下部署的一个项目是在codeigniter中开发的,并且我对nGinx的配置如下:
I've setup ubuntu, php5.6, nGinx on a server and I've deployed few projects under my website configured. One project I need to deploy under a directory is developed in codeigniter and I've configured the nGinx configuration as follows:
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
expires max;
log_not_found off;
}
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 unix:/run/php/php5.6-fpm.sock;
include fastcgi.conf;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
URL现在不说404,但是URL重写后它显示了我网站的主页.我该如何解决?
The URL don't say 404 now but it is showing the home page of my site after URL rewrite. How can I fix this?
推荐答案
实际上,我已经解决了该问题.问题是更改fastcgi_param,它工作正常.谢谢@edlee
Actually, I've fixed the issue. The problem was to change the fastcgi_param and it worked fine. Thanks @edlee
location /6 {
alias /var/www/html/6/;
try_files $uri $uri/ /6/index.php;
}
location ~* \.php$ {
fastcgi_pass unix:/run/php/php5.6-fpm.sock;
root /var/www/html/;
try_files $uri =404;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
这篇关于如何在Ubuntu,nGinx和Codeigniter中启用URL重写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!