Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.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 如何在Nginx上使用mod_rewrite_Php_.htaccess_Mod Rewrite_Nginx_Url Rewriting - Fatal编程技术网

Php 如何在Nginx上使用mod_rewrite

Php 如何在Nginx上使用mod_rewrite,php,.htaccess,mod-rewrite,nginx,url-rewriting,Php,.htaccess,Mod Rewrite,Nginx,Url Rewriting,我想使用Nginx服务器而不是Apache。在我的.htaccess文件中,我有以下几行 RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^.*$ ./nice_urls.php 有没有关于如何在Nginx上工作的想法?Nginx对.htaccess文件没有现成的支持 简单的方法是在nginx配置文件中为您vhost使用以下规则:

我想使用Nginx服务器而不是Apache。在我的
.htaccess
文件中,我有以下几行

RewriteEngine On  

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

RewriteRule ^.*$ ./nice_urls.php

有没有关于如何在Nginx上工作的想法?

Nginx对.htaccess文件没有现成的支持

简单的方法是在nginx配置文件中为您vhost使用以下规则:

try_files $uri $uri/ /nice_urls.php?$args;
在Nginx上,try_文件基本上替代了典型的mod_重写样式的文件/目录存在性检查。它应该比使用if-see更有效

此外,还必须配置Nginx以将脚本\ U文件名返回到应用程序。 如果您使用fastcgi,则必须检查fastcgi.conf以获得以下行:
fastcgi\u参数SCRIPT\u文件名$document\u root$fastcgi\u SCRIPT\u名称

如果该行不存在,请将其添加到fastcgi.conf或vhost config文件中。

它不会存在。