[英]CodeIgniter 3, Nginx rewrite how to?
经过很长时间,我在PHP-fpm和nginx(Ubuntu)上安装了CodeIgniter 3。 以前,我一直在Windows上使用CodeIgniter,并在Windows和Apache上进行配置,这真是小菜一碟。 现在,我想在nginx上安装它,因为我想使用nginx-push-stream-module,这在apache中是不可能的。
现在,当我配置它时,它不起作用。
如果我键入localhost/myexample.com
或localhost/myexample.com/index.php
它就可以工作( myexample.com
是该目录的名称)
但是当我尝试访问
localhost/myexample.com/welcome
要么
localhost/myexample.com/welcome/index
要么
localhost/myexample.com/index.php/welcome
要么
localhost/myexample.com/index.php/welcome/index
它在4种情况下(无论是否带有index.php)均不起作用
我的根目录是/var/www/html/myexample.com
我尝试了不同博客文章等在线提供的所有重写设置(包括以下设置)(因为我不习惯nginx自己)
server {
server_name myexample.com;
root /var/www/html/myexample.com/;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
expires 15d;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/myexample.com/index.php;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}
您应该修改/ etc / hosts并添加以下行:
127.0.0.1 myexample.com
然后,使用myexample.com或myexample.com/welcome访问您的CodeIgniter网站
首先-确认服务器名称是什么。 在您的主机文件中进行设置,然后确认网络根目录。
因此在/ etc / hosts中添加
127.0.0.1 myexample.com
然后,您的index.php文件应位于
/var/www/html/myexample.com/
您应该启动CI并使用url
http://myexample.com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.