【问题标题】:Issue with Magento 1.9 custom url rewritesMagento 1.9 自定义 url 重写问题
【发布时间】:2018-12-18 21:47:01
【问题描述】:

我有一个使用 Magento 1.9 构建的网站,该网站在不同的地方有不同的链接相同的页面。在某些地方,它被链接为/contact-us,而在其他地方,它被链接为/contact-us/。 Magento 将它们视为两个不同的页面。出于 SEO 的目的,我们希望这两个显示为同一个页面。

我尝试在 Magento 管理员中实现自定义 URL 重写并将请求路径设置为:contact-us,并将目标路径设置为:contact-us/,这有效地将/ 添加到路径的末尾,但不知何故,这最终会触发重定向循环。

谁能给点建议?

【问题讨论】:

    标签: php magento redirect url-rewriting


    【解决方案1】:

    从我能找到的所有内容中,无法使用 Magento 管理菜单中的 URL 重写部分修复这个斜杠问题。

    我可以通过直接修改根.htaccess 文件并添加以下内容来解决此问题:

    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteCond %{REQUEST_FILENAME} !\.(gif|jpg|png|jpeg|css|js)$ [NC]
    RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]
    

    分享以防万一这对其他人有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-23
      • 2015-08-25
      • 2019-01-08
      • 2012-08-29
      • 2019-04-17
      • 2014-02-19
      • 1970-01-01
      相关资源
      最近更新 更多