【发布时间】:2018-02-24 13:00:39
【问题描述】:
我想我有点迷路了。
我尝试了一些解决方案,但我没有得到一个部分。一切都必须由 index.php 处理,我无法让它在 nginx 中工作。我一直在学习 Nginx,因为它很棒,但非常感谢某人的快速帮助。
我的 .htaccess:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?_route_=$1 [L,QSA]
我的 Nginx 配置是:
server {
listen 80;
listen [::]:80;
root /folder;
index index.php index.html index.htm index.nginx-debian.html;
server_name hostname.com;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
try_files = $uri @missing;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location @missing {
rewrite ^ $scheme://$host/index.php permanent;
}
}
有人能指出我正确的方向吗?谢谢
【问题讨论】:
-
您的问题到底是什么? “不让它工作”是什么意思?请阅读:stackoverflow.com/help/mcve
-
嘿,Maciej,我的错。我有一个旧的 cms,我的客户希望在他们的新 nginx 服务器上拥有它。问题是应用程序用于工作,因此它采用whatever.php“whatever”并将其用作动态标题。所以 php 应用程序读取 index.php 作为主页。其他任何内容都作为标题,并且有特定页面内容的 mysql 查找。
-
请使用所有这些详细信息编辑您的原始问题。确保您清楚地陈述问题并呈现不希望的和期望的效果。
标签: php apache .htaccess nginx