在Windows Server IIS上实现Toro必需的htaccess重写

我正在我的服务器上安装ToroPHP (PHP路由类)。 但是,这恰好是我的第一个Windows服务器,我正在试着学习它。

这是所需的ModRewrite代码,就好像它是Toro的Apache服务器一样:

RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index\.php) RewriteRule ^(.*)$ /index.php/$1 [L] 

我已经读过这两篇文章/问题,但是对于我的生活,我不知道为什么它不工作。 我希望有人能走过这个“Windows IIS移植版本”的每一部分…

这是我正在尝试,但它似乎并没有工作:

 <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="toro" stopProcessing="true"> <match url="^(.*)$ /index.php/$1" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" pattern="{UrlEncode:{R:1}} !^(index\.php)" /> </conditions> <action type="Rewrite" url="^(.*)$ /index.php/{UrlEncode:{R:1}}" /> </rule> </rules> </rewrite> </system.webServer> </configuration> 

谢谢。

适用于Windows Server的URL重写(IIS)和http://www.iis.net/learn/application-frameworks/install-and-configure-php-applications-on-iis/translate-htaccess-content-to-iis-webconfig

我也使用Toro,这个工作对我来说,但不是根“/”。 在IIS.net上find这个: http ://www.iis.net/learn/extensions/url-rewrite-module/enabling-pretty-permalinks-in-wordpress

 <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Main Rule" stopProcessing="true"> <match url="^(.*)$" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="index.php/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> </configuration> 

为了让root工作,你需要对第11行的Toro.php文件进行修改,将其replace为:

 $path_info = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : (isset($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : $path_info); 

通过

 $path_info = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : ((isset($_SERVER['ORIG_PATH_INFO']) and $_SERVER['ORIG_PATH_INFO'] !== "/index.php") ? $_SERVER['ORIG_PATH_INFO'] : $path_info); 

出于某种原因IIS返回$_SERVER['ORIG_PATH_INFO']等于/index.php而不是/