对于一个大学项目,我在我的开发服务器(localhost)上使用php编写了一个REST api。我必须编辑。htaccess才能使其工作。内容在这里:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* api.php/$0 [L]
但是部署服务器是IIS,我不知道如何配置webconfig文件。我已经试着仔细研究过了,但我不知道该怎么做。
服务器在大学网络上,并且不可能对服务器的主要配置进行任何更改,也不可能安装其他库。
如果它不能简单地完成,那么我确实可以访问我自己的托管Apache服务器,我可以运行它。
我想知道是否有人能够将上述内容转换为我需要的IIS?
编辑:我花了一些时间阅读更多关于重写,根据我的模块领导在服务器上启用。我试图把这些规则写进网络。配置,这是我有:
<?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>
但是行不通。
谢谢
您不需要web.config
。这只适用于。net项目。您需要使用相当于apache的mod_rewrite
的IIS。这篇文章可以帮助你在IIS上配置重写规则。