对于大学项目,我在我的开发服务器(localhost)上使用php编写了一个REST API。我必须编辑.htaccess才能工作。内容如下:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* api.php/$0 [L]
但部署服务器是IIS,我不知道如何配置webconfig文件。我试图阅读它,但我不知道该怎么做。
服务器位于大学网络上,并且不可能对正在进行的服务器的主要配置或正在安装的其他库进行任何更改。
如果不能简单地完成,那么我可以访问我自己的托管Apache服务器,我可以从中运行它。
我想知道是否有人能够将上述内容转换为IIS所需的内容?
编辑:我花了一些时间阅读有关重写的更多内容,根据我的模块负责人在服务器上启用了重写。我试图将规则写入web.config,这就是我所拥有的:<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<customErrors mode="Off"/>
</system.web>
<system.webServer>
</system.webServer>
<rewrite>
<rules>
<rule name="Rewrite to server.php">
<match url="^([0-9]+)/([_0-9a-z-]+).*" />
<action type="Rewrite" url="api.php" />
</rule>
</rules>
</rewrite>
</configuration>
但它不起作用。
由于
答案 0 :(得分:1)
您不需要web.config
。这仅适用于.Net项目。您需要使用与apache的mod_rewrite
等效的IIS。这篇文章应该有助于在IIS上配置重写规则。
http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module