重写时从网址中删除部分

时间:2013-09-07 18:27:22

标签: magento iis url-rewriting web-config

我有一个Magento安装,想要重写网址并删除index.php和尾随' /'从它

e.g。改写 http://www.domain.com/index.php/http://www.domain.com http://www.domain.com/index.php/customer/account/login/http://www.domain.com/customer/account/login

等等 所以不是这两个网址,而是所有网址。

我目前在我的web.config中有这个:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration>
<system.webServer>
<rewrite>
<rules>
    <rule name="Magento SEO: remove index.php from URL">
    <match url="^(?!index.php)([^?#]*)(\\?([^#]*))?(#(.*))?" />
    <conditions>
    <add input="{URL}" pattern="^/(media|skin|js)/" ignoreCase="false" negate="true" />
    <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/{R:0}" />
    </rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

使用上面的web.config,网址似乎根本没有重写,但只是保持原样。

1 个答案:

答案 0 :(得分:4)

根据我的建议,事情无法帮助你。

但是当我遇到问题时,您可以按照以下方式解决问题。

第1步:转到您的站点根文件夹,然后在那里找到htaccess文件。在文本编辑器上打开它,找到行#Rewrite Base/ magento。只需将其替换为Rewrite Base/

即可

第2步:然后转到管理面板并启用重写(对“使用Web服务器重写”设置为“是”)。您可以在System->Configuration->Web->Search Engine Optimization找到它。

第3步:然后转到缓存管理页面(系统缓存管理)并刷新缓存并刷新以检查网站。

希望这会对你有所帮助。

相关问题