代码点火器应用程序的Web配置文件


Web Config file for a codeigniter application

我遇到了一个web配置文件,它没有重写我的代码点火器应用程序的url。这是web配置文件。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <rewrite>
        <rules>
            <rule name="Clean URL" stopProcessing="true">
                <match url=".*" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                </conditions>
                <action type="Rewrite" url="index.php?{R:1}" appendQueryString="true" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>
</configuration>

这是我的网站:http://gandhitomodi.com

我无法获得这种urlhttp://gandhitomodi.com/controller/method/

例如

http://gandhitomodi.com/welcome/index/

请帮我渡过难关。

****编辑*****

这是route.php

$route['default_controller']="welcome/index";
$route['sendmail']="welcome/send";

这是我更改的config.php设置。

$config['base_url']="http://gandhitomodi.com/";
$config['index_page']='';
$config['url_protocal']='PATH_INFO';`

你尝试过这里提到的这种方法吗

https://blogs.msdn.microsoft.com/azureossds/2015/04/23/converting-apache-htaccess-rules-to-iis-web-config-using-iis-manager-for-azure-websites/

这里也提到

https://blogs.msdn.microsoft.com/azureossds/2015/09/28/convert-apache-htaccess-to-iis-web-config/

在URL重写部分。它有相同的.htaccess,我正在使用它还有许多在线转换器,你可以尝试

对于您的配置文件,请尝试本文。看来你的问题就在你的行动线上。

<action type="Rewrite" url="index.php?{R:1}" appendQueryString="true" />

将其更改为:

<action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />

问号引起了你的问题。此外,您的匹配线可能会更改为:

<match url="^(.*)$" ignoreCase="false" />

这是一个更具体的,可能会防止以后出现一些头痛。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Imported Rule 1" stopProcessing="true">
          <match url="^(.*)$" ignoreCase="false" />
          <conditions logicalGrouping="MatchAll">
              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
              <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" />
          </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

你可以尝试这个代码,它会很好地工作,我也只使用这个代码

感谢

我在使用mssql、windows服务器和codeigner平台时也遇到了问题。我很难从url中删除index.php,或者你可以说是漂亮的url。经过大量的讨论和研究;d.我在服务器根目录下的webcofing文件中做了一些更改。

重写web配置的规则以删除index.php:

    <configuration>
    <appSettings>
         // default code..
    </appSettings>
    <system.webServer>
        <handlers>
            <clear />
// another default code
 </handlers>
        <rewrite>
              <rules>
                <rule name="Rule" stopProcessing="true">
                  <match url="^(.*)$" ignoreCase="false" />
                  <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
                  </conditions>
                  <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
                </rule>
              </rules>
            </rewrite> 
    </system.webServer>
</configuration>

它的工作和剩余的部分代码点火器工作良好。同样重要的是在routes.php和config.php中设置默认url等设置。如果有其他帮助,请写下您的评论。

首先,我们需要从url 中删除index.php

因此,在route.php中,您将更改行

$route['default_controller'] = "welcome";
$route['404_override'] = 'notfound';

config.php中,您将更改行

$config['uri_protocol'] = 'AUTO';

之后,您需要在网站的根目录中添加.htaccess文件,如下所示:

/application
/system
/assets
/.htaccess

并将此代码添加到.htaccess文件

Header append X-FRAME-OPTIONS "SAMEORIGIN"
Header set Cache-Control "no-store"
Header set X-Content-Type-Options "nosniff"
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains"
ErrorDocument 403 /notfound.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L] 

<IfModule !mod_rewrite.c>
        # If we don't have mod_rewrite installed, all 404's
        # can be sent to index.php, and everything works as normal.
        # Submitted by: ollakalla
    ErrorDocument 404 /index.php
</IfModule> 

然后您可以访问控制器中的方法,如本例所示

class Reviews extends CI_Controller 
{
    public function latest()
    {
         // Some code here
    } 
}

由http://gandhitomodi.com/reviews/latest/