需要 web.config 文件而不是 codeigniter 的 .htaccess

Need a web.config file instead of .htaccess for codeigniter(需要 web.config 文件而不是 codeigniter 的 .htaccess)
本文介绍了需要 web.config 文件而不是 codeigniter 的 .htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我仍然无法让 web.config 文件工作,无论我如何尝试它仍然无法重定向到其他页面.我正在使用 codeigniter 并在 IIS 平台上托管应用程序,这里是我的 .htaccess 文件,请问有人可以将此代码转换为 web.config 吗?

I still not able to get the web.config file working no matter how I try it still does not redirect to other pages. I am using codeigniter and hosting the application in IIS platform here is my .htaccess file, please can anyone convert this code to web.config?

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /travel/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
  ErrorDocument 404 /index.php
</IfModule>

推荐答案

您的 web.config 文件应如下所示:

Your web.config file should look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <rewrite>
        <rules>
            <rule name="Index">
                <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}"/>
            </rule>                
        </rules>
    </rewrite>
    <httpErrors>
        <remove statusCode="404" subStatusCode="-1" />                
        <error statusCode="404" path="/somedir/oops404.htm" responseMode="ExecuteURL" />                       
    </httpErrors>      
</system.webServer>

在 web.config 文件中未按原样使用 RewriteBase,因此您可能需要相应地更改 URL 路径.

RewriteBase is not used in web.config files as is, so you may need to change the URL paths accordingly.

这篇关于需要 web.config 文件而不是 codeigniter 的 .htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Codeigniter htaccess to remove index.php and www(Codeigniter htaccess 删除 index.php 和 www)
htaccess mod_rewrite part of url to GET variable(htaccess mod_rewrite url 的一部分到 GET 变量)
Replacing a querystring parameter value using mod_rewrite(使用 mod_rewrite 替换查询字符串参数值)
.htaccess in subdirectory #39;overriding#39; parent htaccess(子目录“覆盖父 htaccess 中的 .htaccess)
How to rewrite SEO friendly url#39;s like stackoverflow(如何像stackoverflow一样重写SEO友好的url)
Is it okay to have a very long .htaccess file?(有一个很长的 .htaccess 文件可以吗?)