[英]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.