簡體   English   中英

htaccess的magento index.php單一家庭URL重寫規則?

[英]htaccess rewrite rule for magento index.php single home URL?

默認情況下,Magento會監聽3個可能的網址以訪問首頁:

  1. https://www.shop.nl/
  2. https://www.shop.nl/index.php
  3. https://www.shop.nl/index.php/

Google不喜歡這種行為,我正在嘗試針對搜索引擎優化我的商店。 因此,我轉到了Magento的.htaccess文件,並嘗試編輯正確的規則。 但是,這似乎不起作用。

我嘗試將175行: RewriteRule .* index.php [L]替換為:

RewriteCond %{REQUEST_URI} !^/index.php/admin($|/)
RewriteRule ^index.php(/(.*))? /$2 [R=301,QSA,L]

這是因為在我看來magento的后端不喜歡我從URL中刪除index.php。 它適用於根URL。 但問題是我無法查看任何其他頁面。 全部將我重定向到主頁。

有人有什么建議嗎? 我也想弄清楚為什么magento會這樣做。 我不知道這怎么有用。

注意:我想知道在suPHP上運行是否重要

將此規則添加為您的magento .htaccess中的第一條規則

RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php/?$ /$1 [L,R=301,NC,NE]

這將從原始URL(而不是從重寫的URI)中刪除index.php

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM