简体   繁体   English

如何在NGINX服务器中配置Codeigniter? .htaccess无法正常工作

[英]How can I configure Codeigniter in NGINX server? .htaccess not working

How can I configure Codeigniter in NGINX server? 如何在NGINX服务器中配置Codeigniter? .htaccess is not working here and i have no root permission . .htaccess在这里不起作用,我没有root权限 Only I can upload files using FTP and can access database. 只有我可以使用FTP上传文件并可以访问数据库。

where can I use this config...? 我在哪里可以使用此配置...?

    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;
        }
}

Ref: https://www.nginx.com/resources/wiki/start/topics/recipes/codeigniter/ 参考: https : //www.nginx.com/resources/wiki/start/topics/recipes/codeigniter/

You should talk to your network admin for access of configuration files /etc/nginx/conf.d/default.conf. 您应该与网络管理员联系,以访问配置文件/etc/nginx/conf.d/default.conf。 which needs to be configured correctly to make your routing work.you can configure your nginx server file like this code to make your routing work. 需要正确配置才能使路由正常工作。您可以像以下代码一样配置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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM