将codeigniter .htaccess更改为web.config错误 [英] change codeigniter .htaccess to web.config error

查看:49
本文介绍了将codeigniter .htaccess更改为web.config错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在IIS上使用codeigniter,我能够将php配置为在IIS上工作,但是当我尝试将.htaccess更改为web.config时,它给我错误

I trying to use codeigniter on IIS, I was able to config php to work on IIS but when I tried to change the .htaccess to web.config it gives me error

我的htaccess代码是

my htaccess code is

RewriteEngine on
Options +FollowSymLinks

RewriteRule ^admin(.*) index.php/admin$1
RewriteRule ^supervisor/([0-9]+)(.*) index.php/supervisor_$1/$2
RewriteRule ^moder/(.*)/([0-9]+)(.*) index.php/moder/$1/$2
rewriteRule ^(login|logoff)(.*) index.php/base/$1$2
RewriteRule ^(attachment|meeting|thread|attachments|profile|search|roles|cat)(.*) index.php/moder/$1$2
RewriteRule ^(about|contact|new_majlis|sk|supervideo|superandsk|guest)(.*) index.php/page/$1$2
RewriteRule ^(2.2-release-notes)(.*) index.php/page/release_notes
RewriteRule ^page/(change_lang)/(.*) index.php/page/$1/$2

以及我的web.config代码:

and for my web.config code :

       <rewrite>
            <rules>
<rule name="rule 1m">
    <match url="^admin(.*)"  />
    <action type="Rewrite" url="/index.php/admin{R:1}"  />
</rule>
<rule name="rule 2m">
    <match url="^supervisor/([0-9]+)(.*)"  />
    <action type="Rewrite" url="/index.php/supervisor_{R:1}/{R:2}"  />
</rule>
<rule name="rule 3m">
    <match url="^moder/(.*)/([0-9]+)(.*)"  />
    <action type="Rewrite" url="/index.php/moder/{R:1}/{R:2}"  />
</rule>
<rule name="rule 4m">
    <match url="^(login|logoff)(.*)"  />
    <action type="Rewrite" url="/index.php/base/{R:1}{R:2}"  />
</rule>
<rule name="rule 5m">
    <match url="^(attachment|meeting|thread|attachments|profile|search|roles|cat)(.*)"  />
    <action type="Rewrite" url="/index.php/moder/{R:1}{R:2}"  />
</rule>
<rule name="rule 6m">
    <match url="^(about|contact|new_majlis|sk|supervideo|superandsk|guest)(.*)"  />
    <action type="Rewrite" url="/index.php/page/{R:1}{R:2}"  />
</rule>
<rule name="rule 7m">
    <match url="^(2.2-release-notes)(.*)"  />
    <action type="Rewrite" url="/index.php/page/release_notes"  />
</rule>
<rule name="rule 8m">
    <match url="^page/(change_lang)/(.*)"  />
    <action type="Rewrite" url="/index.php/page/{R:1}/{R:2}"  />
</rule>
            </rules>
        </rewrite>

我仍然看到此屏幕

推荐答案

Codeigniter拥有自己的路由类,这将使您的生活变得更加简单,尤其是在可能在服务器操作系统之间进行切换的情况下.

Codeigniter has it's own routing class which will make you're life much more simple especially if there is possibility of switching between Server OS's.

以下web.config文件是使CI与IIS一起使用的基本知识:

The following web.config file is the bare basics of getting CI to work with IIS:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <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=".*" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" pattern="css|js|jpg|jpeg|png|gif|ico|htm|html|ttf|woff" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:0}" />
                </rule>
            </rules>
        </rewrite>
     </system.webServer>
</configuration> 

然后在 application/config/routes.php 中,示例行为

$route['page/(change_lang)/(.*)'] = 'page/$1/$2';

希望这会有所帮助!

这篇关于将codeigniter .htaccess更改为web.config错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆