【发布时间】:2023-03-26 21:00:01
【问题描述】:
【问题讨论】:
-
这表示您的网址不可用。请通过这个stackoverflow.com/help/how-to-ask
-
您的控制器名称是什么?给我看看你的
redirect行的代码。 -
如果使用
nginx,则不需要.htaccess标签。
标签: php .htaccess codeigniter
【问题讨论】:
redirect 行的代码。
nginx,则不需要.htaccess标签。
标签: php .htaccess codeigniter
首先,通过 ssh 连接您的服务器并发送以下命令:
nginx -t
它将测试您的 nginx 配置文件并显示配置文件的路径。然后打开您的配置文件并将这些添加到 html {} 部分(在include /etc/nginx/conf.d/*.conf; 行之前):
server {
server_name yourdomain.tld;
root /your/codeigniters/full/path;
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;
}
}
如果与nginx.conf在同一文件夹中没有fastcgi.conf,请创建一个并添加以下行:
#fastcgi.conf
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
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_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
就是这样!
【讨论】:
nginx -t 并按 Enter。你会看到 nginx.conf 路径。
nginx -t发给我输出吗?