本文介紹了需要 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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!