Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.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 使用IIS URL重写模块找不到文件时如何重写URL_Php_Iis_Url Rewrite Module - Fatal编程技术网

Php 使用IIS URL重写模块找不到文件时如何重写URL

Php 使用IIS URL重写模块找不到文件时如何重写URL,php,iis,url-rewrite-module,Php,Iis,Url Rewrite Module,我需要在IIS上运行PHP应用程序,我正在尝试移植htaccess规则,如下所示: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?%{QUERY_STRING} [NE,L] </IfModule>

我需要在IIS上运行PHP应用程序,我正在尝试移植htaccess规则,如下所示:

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ index.php?%{QUERY_STRING} [NE,L]
</IfModule>

重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?%{QUERY_STRING}[NE,L]
我在htaccess方面没有任何经验,但我被告知,这些规则规定,如果找不到该文件,则应将请求发送到index.php,并应继续执行查询字符串。请注意,这不是用户浏览器的重定向,而是传输所有post数据的纯服务器操作


那么,如何使用IIS URL重写模块创建这些规则呢?根据原始地址上丢失的文件,我应该使用什么规则重写URL?我正在IIS7上尝试这样做,如果您使用IIS URL重写模块,您应该能够直接导入.htaccess

当您在IIS中需要此功能的站点上时,双击URL重写图标,然后在右侧有一个“导入规则…”链接。点击这个,在你的.htaccess中打开窗口,点击“导入”,一切都会正常


这太酷了。我有一些错误的标志,但现在我们可以删除它们,它的工作足够好的测试。非常感谢,我不敢相信我在网上搜索时没有看到一篇文章提到这个功能。