将PHP网站复制到IIS 8.5下的虚拟文件夹

时间:2016-02-25 17:08:29

标签: php iis web-config rewrite virtual-directory

我想在IIS 8.5下的虚拟文件夹上运行现有的PHP网站(Apache)。

借助一些不错的在线工具,我翻译了以下.htaccess内容

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

到web.config:

<rule name="rule 1" stopProcessing="true">
  <match url="^index\.php$"  />
  <action type="Rewrite" url="/-"  />
</rule>
<rule name="rule 2" stopProcessing="true">
  <match url="."  />
  <action type="Rewrite" url="//index.php"  />
</rule>

这适用于某些网址,例如http://www.my_new_website.com/

但是,我的目标是让这个网站在ASP.NET网络应用程序下的虚拟目录中运行,例如http://www.my_asp_net_website/php_app/。因此我创建了一个虚拟目录&#34; php_app&#34;在IIS管理器中指向目录 C:\ ... \&lt; webroot&gt; \ myphpdir ,就像我为ASP.NET应用程序所做的那样。

现在我必须调整我的web.config;但由于我不太熟悉重定向/重写规则和正则表达式,我问

web.config中有哪些正确的重写规则?

我所尝试的所有内容都导致了一些错误的.c​​ss或404错误。

0 个答案:

没有答案