2013-03-09 55 views
2

对于大学项目,我在开发服务器(localhost)上使用php编写了REST api。我不得不编辑.htaccess才能正常工作。内容在这里:为php REST API编写web.config

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

'.htaccess'是Apache,'web.config'为IIS。你在混合两个吗? – Dai 2013-03-09 02:18:58

+0

http://www.iis.net/learn/application-frameworks/install-and-configure-php-applications-on-iis/translate-htaccess-content-to-iis-webconfig – Amir 2013-03-11 05:19:20

回答