【问题标题】:Magento - urls with index.php do not redirectMagento - 带有 index.php 的网址不会重定向
【发布时间】:2015-09-20 01:08:14
【问题描述】:

这是标准“如何从 magento url 中删除 index.php”问题的细微变化。

我已经实现了this answer 中提到的更改,并且网站上生成的 url 不再显示 index.php。

但是,更进一步,指向仍然在 url 中的 index.php 的站点的旧链接仍然有效。

例如www.mydomain.com/index.php/page1 在网上某处被提及,用户点击该网站的链接。它没有重定向到 www.mydomain.com/page1,而是保持原样,并且仍然在我们的分析中作为单独的 url 提取。

我不熟悉 LAMP 环境(仍在学习曲线上!),所以我不习惯 mod_rewrite 规则。您可以提供任何帮助来教育我如何构建规则,以便它从 url 中删除 index.php 并将 301 重定向到其余部分!

谢谢!

【问题讨论】:

    标签: magento mod-rewrite redirect


    【解决方案1】:

    您可以通过 .htaccess 重定向 .index.php 或其他 url

    <IfModule mod_rewrite.c>   
    RewriteEngine On  
    RewriteBase /  
    RewriteRule ^index\.php$ - [L]    
    RewriteCond %{REQUEST_FILENAME} !-f    
    RewriteCond %{REQUEST_FILENAME} !-d   
    RewriteRule . /index.php [L]     
    </IfModule>
    

    这只会将 www.website.com/index.php 重定向到 www.website.com 还在 Magento Admin 的索引管理中重新索引数据

    【讨论】:

    • 太好了!谢谢!这解决了在主页上重定向 index.php 的一个问题。不过,我仍然需要找到一种方法从 url 中删除 index.php。我确实找到了一个看起来可行的解决方案(见下文),但它破坏了仍然需要它的管理 url。 RedirectMatch 301 /index.php/(.*) http://www.example.com/$1
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-19
    • 2018-05-29
    • 1970-01-01
    • 2017-05-01
    相关资源
    最近更新 更多