Magento多语言部署-子域名

比如主域名是www.vfeelit.com,默认是英语,当切换到法语时使用fr.vfeelit.com来访问。magento中支持店铺,这个控制代码在index.php中:

/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
 
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
 
Mage::run($mageRunCode, $mageRunType);

实际上,只需要设置MAGE_RUN_CODE 和 MAGE_RUN_TYPE就能定位到不同店铺,如下是Apache 和 Nginx中的配置参考:

// Nginx-------------------->
server {
    listen 80;
    server_name www.vfeelit.com;
    root /www/vfeelit.com/public_html;
    ///.....
}
server {
    listen 80;
    server_name fr.vfeelit.com;
    root /www/vfeelit.com/public_html;
    ///.....
    location ~ .php$ {
        if (!-e $request_filename) { rewrite / /index.php last; }
        expires        off;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_param  HTTPS $fastcgi_https;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  MAGE_RUN_CODE fr_lan;  ##指定代码
        fastcgi_param  MAGE_RUN_TYPE store;
        include        fastcgi_params;
    }
}
 
// Apache---------------------->
<VirtualHost *:80>
    DocumentRoot "/www/vfeelit.com/public_html"
    ServerName vfeelit.com
 
    <Directory "/www/vfeelit.com/public_html">
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>  
</VirtualHost>
 
<VirtualHost *:80>
    DocumentRoot "/www/vfeelit.com/public_html"
    ServerName fr.vfeelit.com
 
    SetEnv MAGE_RUN_CODE "fr_lan"    ##指定代码
    SetEnv MAGE_RUN_TYPE "website"
 
    <Directory "/www/vfeelit.com/public_html">
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>  
</VirtualHost>

这样PHP的$_SERVER数组就有这两个环境变量了。那么它就会定位到不同的店铺,最后还需要到后台去针对每个店铺设置正确的URL,比如法语的店铺,必须修改为fr.vfeelit.com。

相应资料
http://www.coeusblue.com/blog/48-magento/68-nginxmagentomultisite

http://briansnelson.com/Nginx_Magento_vhost_Configuration

http://twincreations.co.uk/vhost-configuration-to-host-magento-on-nginx/

还没有评论,快来抢沙发!

发表评论

  • 😉
  • 😐
  • 😡
  • 😈
  • 🙂
  • 😯
  • 🙁
  • 🙄
  • 😛
  • 😳
  • 😮
  • emoji-mrgree
  • 😆
  • 💡
  • 😀
  • 👿
  • 😥
  • 😎
  • ➡
  • 😕
  • ❓
  • ❗
  • 67 queries in 0.433 seconds