[英]How can I configure Codeigniter in NGINX server? .htaccess not working
如何在NGINX服務器中配置Codeigniter? .htaccess在這里不起作用,我沒有root權限 。 只有我可以使用FTP上傳文件並可以訪問數據庫。
我在哪里可以使用此配置...?
server {
server_name domain.tld;
root /var/www/codeignitor;
index index.html index.php;
# set expiration of assets to MAX for caching
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 127.0.0.1:9000;
include fastcgi.conf;
}
}
參考: https : //www.nginx.com/resources/wiki/start/topics/recipes/codeigniter/
您應該與網絡管理員聯系,以訪問配置文件/etc/nginx/conf.d/default.conf。 需要正確配置才能使路由正常工作。您可以像以下代碼一樣配置nginx服務器文件以使路由正常工作。
server{ listen 80; listen [::]:80; server_name 192.168.56.101 192.168.101.100 localhost; root /var/www/html; index index.php index.html index.htm; location / { try_files $uri $uri/ =404; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www/html; } location /ci { try_files $uri $uri/ /ci/index.php?/$request_uri; }location ~ \.php$ { try_files $uri $uri/ /ci/index.php?/$request_uri; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.