嗨,我有一个网站在codeigniter工作完美的wamp在loacl服务器,但当我上传的文件在我的在线服务器是iis7.5,主页工作良好,但当我打开其他页面,如mysite.com/products
,它给出错误,但当我把网址像这样的mysite.com/index.php/products
,然后它的工作正常。在上传文件之前,我删除了服务器上的一些文件夹,iis的一些配置文件夹。如何创建web.config文件。配置文件夹是否有层次结构?
发布于 2014-03-13 02:49:24
使用IIS管理器中的url重写工具导入删除URL中index.php的.htaccess文件。这将创建一个IIS web.config文件。您的.htaccess应该如下所示:
<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文件将如下所示:
<?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>
https://stackoverflow.com/questions/22347277
复制相似问题