doulangxun7769 2014-07-16 09:11
浏览 55

使用位置前缀Magento URL(htaccess / URL重写)

So I'm setting up a Magento installation off the back of a WordPress installation; so at:

  • root.level/ is WordPress
  • root.level/shop/ is Magento

All elements of the website, except the catalogue are being handled through WordPress. Magento only deals with the catalogue.

The website is to be completely localised for the UK, rest of Europe and US markets. On WordPress, I've achieved this effectively using the qTranslate plugin, so all the following are working:

  • root.level/uk/
  • root.level/eu/
  • root.level/us/

In Magento, I've created 3 storefronts and using the configuration I've managed to make them appear as:

  • root.level/shop/uk/
  • root.level/shop/eu/
  • root.level/shop/us/

However, for consistency I would prefer for the 1st URL segment to always represent the locality. I have therefore written the following to the root (WordPress installation) htaccess:

#shop moves
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([a-z][a-z])/shop/(.*)[/]{0,1}$ /shop/index.php?___store=$1 [L]
RewriteRule ^([a-z][a-z])/shop[/]{0,1}$ /shop/index.php?___store=$1 [L]
</IfModule>

Which has the desired effect in so much as root.level/uk/shop/ will load up the UK magento storefront homepage, and root.level/uk/shop/xyz.html has the desired behavior. The problem is that the links on the store page are still pointing to root.level/shop/xyz.html. How do I go about making the links reflect the rewritten URLs?

I've tried going in to Magento Admin-->System-->Config, setting the scope to the relevant store front then under Web changing the "Link URL" (under both Secure and Insecure) and while this corrects the links it makes every page 404 (including the homepage) on that storefront. Is there somewhere I need to edit Magento's URL reading behavior?

Edit: So this is weird. I've got it working on /eu/shop/ and /us/shop/ but /uk/shop/ is still returning 404s. I thought it was because the UK was set to default but changing that doesn't seem to affect things. Any ideas?

  • 写回答

1条回答 默认 最新

  • 普通网友 2014-07-16 10:15
    关注

    You can use this .htaccess to get it work :

    <IfModule mod_rewrite.c>
    
      RewriteEngine On
      RewriteBase /
    
      # Redirect old /shop/uk/ to new /uk/shop
      RewriteCond %{THE_REQUEST} ^/shop/([a-z]{2})(.*)$ [NC]
      RewriteRule ^ %1/shop/%2 [R=302,L]
    
      # Load the right file for new /uk/shop
      RewriteRule ^([a-z]{2})/shop/(.*)/?$ /shop/index.php?___store=$1 [L]
      RewriteRule ^([a-z]{2})/shop/?$      /shop/index.php?___store=$1 [L]
    
    </IfModule>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?