Need a web.config file instead of .htaccess for codeigniter(需要 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:需要 web.config 文件而不是 codeigniter 的 .htaccess


- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- PHP - if 语句中的倒序 2021-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01