我有一个网站,我已经安装了Gallery3。网址是将Gallery3 .htaccess mod_rewrite代码转换为IIS URL在Web.config中重写
http://techblog.lalsofttech.com/gallery/
但是当我打开“测试专辑”,在URL中存在的index.php
http://techblog.lalsofttech.com/gallery/index.php/test
现在我想的是从URL中删除index.php文件和想要的网址看起来像这样
http://techblog.lalsofttech.com/gallery/test
因为我的共享服务器空间是一个Windows平台的IIS 7,我不能使用.htaccess文件。 由于我的服务器得到了Microsoft URL重写模块安装,我需要在web.config文件中写入重写规则。
这是隐藏的index.php .htaccess文件中
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /gallery
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?kohana_uri=$1 [QSA,PT,L]
RewriteRule ^$ index.php?kohana_uri=$1 [QSA,PT,L]
RewriteRule ^index.php/(.*) $1 [QSA,R,L]
</IfModule>
我想在我的本地安装Microsoft URL重写模块转换该代码。
除了“RewriteBase/gallery”所有其他代码被转换之外,“RewriteBase/gallery没有被转换,因为它不被IIS支持”是我得到的错误消息。 这是转换后的代码。
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?kohana_uri={R:1}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^$" ignoreCase="false" />
<action type="Rewrite" url="index.php?kohana_uri={R:1}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 3" stopProcessing="true">
<match url="^index.php/(.*)" ignoreCase="false" />
<action type="Redirect" redirectType="Found" url="{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
但它似乎代码不工作,因为index.php仍然存在。 ISS URL重写模块正在工作,因为我在web.config中添加的另一个规则“强制规范主机名”工作正常。
这是我完整的web.config文件。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<rewrite>
<rules>
<rule name="Enforce canonical hostname" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www\.moviega\.com$" />
</conditions>
<action type="Redirect" url="http://www.moviega.com/{R:1}" redirectType="Permanent" />
</rule>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?kohana_uri={R:1}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^$" ignoreCase="false" />
<action type="Rewrite" url="index.php?kohana_uri={R:1}" appendQueryString="true" />
</rule>
<rule name="Imported Rule 3" stopProcessing="true">
<match url="^index.php/(.*)" ignoreCase="false" />
<action type="Redirect" redirectType="Found" url="{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
那么问题在哪里?应该做什么从url中删除index.php? 请帮我解决这个问题。
,我已经做了,我已经张贴在这里http://forums.iis.net/t/1186418.aspx但w如果我曾经访问过我的网站,比如http://www.MovieGa.com/gallery/,则会出现另一个错误“HTTP错误500.50 - URL重写模块错误。 表达式“index.php?kohana_uri = {R:1}”无法展开“但是如果我在url中调用index.php页面,一切正常,你可以看到我在这里提到的错误http: //techblog.lalsofttech.com/Gallery/ – Shijilal
我已经更新了上面的答案;从“导入的规则2”中取出'?kohana_uri = {R:1}'为您工作吗? – summea
谢谢你解决了那个错误500问题..但再次有一个问题,在这个网页http://techblog.lalsofttech.com/Gallery在这里,如果我们移动任何相册或链接的移动,你可以看到index.php将在那里,这是不应该在那里..像这样http://techblog.lalsofttech.com/Gallery/index.php/test。如果我们点击它,在index.php不会在那里的下一页网址,没关系..但是在主页的所有链接中显示index.php并不好,不应该在那里 – Shijilal