首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >codeigniter .htaccess在iis 7.5中不起作用

codeigniter .htaccess在iis 7.5中不起作用
EN

Stack Overflow用户
提问于 2014-03-12 17:37:02
回答 1查看 2.5K关注 0票数 0

嗨,我有一个网站在codeigniter工作完美的wamp在loacl服务器,但当我上传的文件在我的在线服务器是iis7.5,主页工作良好,但当我打开其他页面,如mysite.com/products,它给出错误,但当我把网址像这样的mysite.com/index.php/products,然后它的工作正常。在上传文件之前,我删除了服务器上的一些文件夹,iis的一些配置文件夹。如何创建web.config文件。配置文件夹是否有层次结构?

EN

回答 1

Stack Overflow用户

发布于 2014-03-13 02:49:24

使用IIS管理器中的url重写工具导入删除URL中index.php的.htaccess文件。这将创建一个IIS web.config文件。您的.htaccess应该如下所示:

代码语言:javascript
运行
复制
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /yourappfolder

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#‘system’ can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn’t true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

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

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

代码语言:javascript
运行
复制
<?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="{URL}" pattern="^system.*" ignoreCase="false" />
                    </conditions>
                    <action type="Rewrite" url="/index.php/{R:1}" />
                </rule>
                <rule name="Imported Rule 2" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                        <add input="{R:1}" pattern="^(index\.php|images|robots\.txt|css)" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22347277

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档