Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将htaccess转换为Nginx_Php_.htaccess_Nginx - Fatal编程技术网

Php 将htaccess转换为Nginx

Php 将htaccess转换为Nginx,php,.htaccess,nginx,Php,.htaccess,Nginx,各位用户好 我在网上找到了一本关于PHP路由的不错的教程。我的问题是,我正在服务器上使用Nginx。我测试了在互联网上找到的一些解决方案,但没有任何效果:( 对于像Laravel这样的框架,我正在使用: location / { try_files $uri $uri/ /index.php?$query_string; } 这是教程中的.htaccess: DirectoryIndex index.php RewriteEngine on RewriteBase /MYBASEPAT

各位用户好

我在网上找到了一本关于PHP路由的不错的教程。我的问题是,我正在服务器上使用Nginx。我测试了在互联网上找到的一些解决方案,但没有任何效果:( 对于像Laravel这样的框架,我正在使用:

location / {
  try_files $uri $uri/ /index.php?$query_string;
}
这是教程中的.htaccess:

DirectoryIndex index.php

RewriteEngine on

RewriteBase /MYBASEPATH

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php [QSA]
这应该起作用:

location / {
    try_files $uri $uri/ /index.php?$query_string;

    rewrite ^/(.*)$ /index.php/$1;
}
这应该起作用:

location / {
    try_files $uri $uri/ /index.php?$query_string;

    rewrite ^/(.*)$ /index.php/$1;
}