【发布时间】:2022-01-13 02:55:49
【问题描述】:
我有这样三种类型的网址:
http://log.cb.gq/index.php/creative-thinking-workshop-de
http://log.cb.gq/work.php/creative-thinking-workshop-de
http://log.cb.gq/cat.php/creative-thinking-workshop-de
而nginx conf是这样的
location / {
try_files $uri $uri/ /index.php$is_args$args;
#rewrite ^/([a-zA-Z0-9]+)/?$ /index.php?$1;
}
并且只有第一个 url 即 index.php 有效。我怎样才能使这三个工作都起作用
【问题讨论】:
-
其他 URL 会发生什么?您是否从 Nginx 获得某个状态码?还是你得到一个 PHP 级别的错误?
-
它显示 index.php 的内容和 work.php/creative-thinking-workshop-de 的路线以及 ofcource no css
-
但它在没有 htaccess 的 apache 的 localhost 上工作正常
-
所以页面正在加载,而不是资源?如果是这样,请检查服务器和/或浏览器控制台日志是否有错误,并查看它们尝试加载的路径。
-
正确的解决方案是更改
location ~ \.php$块,使其与您问题中的 URI 匹配。 For example 与:location ~ [^/]\.php(/|$)
标签: php nginx nginx-config