从web.config迁移到Angular/Codeigniter项目中的.htaccess

问题描述:

我们有一个包含两部分的Codeigniter项目。构建在Angular和后端(API)上的前端。所有的Angular-code都在/ app /中,CI的控制器和配置位于/ _api /文件夹中。 webapp的基础位于“开始”控制器中。从web.config迁移到Angular/Codeigniter项目中的.htaccess

我们正试图将Web服务器从IIS迁移到Ubuntu 16.04,并开始遇到问题,因为我们之前没有使用过.htaccess文件。现在,只要我们尝试去,我们只会在CI的404页上结束。

这里的web.config中:

<configuration> 
    <system.web> 
    <customErrors mode="Off" /> 
    </system.web> 
    <system.webServer> 
    <rewrite> 
     <rules> 
     <rule name="Rewrite to index.php"> 
      <match url="index.php|robots.txt|images|test.php" /> 
      <action type="None" /> 
     </rule> 
     <rule name="Rewrite CI Index"> 
      <match url="api/*" /> 
      <conditions> 
      <add input="{REQUEST_FILENAME}" pattern="js" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="index.php/api/{R:0}" /> 
     </rule> 
     <rule name="Rewrite CI Index 2"> 
      <match url=".*" /> 
      <conditions> 
      <add input="{REQUEST_FILENAME}" pattern="css|js|jpg|jpeg|png|gif|ico|htm|html|eot|woff|ttf|svg|php" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="index.php/start/" /> 
     </rule> 
     </rules> 
    </rewrite> 
    <caching enabled="false"></caching> 
    <staticContent> 
     <clientCache cacheControlMode="DisableCache" /> 
     <remove fileExtension=".woff" /> 
     <!-- In case IIS already has this mime type --> 
     <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" /> 
     <remove fileExtension=".woff2" /> 
     <!-- In case IIS already has this mime type --> 
     <mimeMap fileExtension=".woff2" mimeType="application/x-font-woff2" /> 
    </staticContent> 
    </system.webServer> 
</configuration> 

好吧!问题主要不是真正的.htaccess文件。最大的问题是从基于Windows的Web服务器转向基于Linux的服务器。我们发现我们必须重新命名我们所有的CI控制器和模型,以大写字母开头。