.htaccess-Magento网站下的Wordpress,带有多语言子目录 [英] .htaccess - Wordpress under Magento site with multi language sub directories

查看:75
本文介绍了.htaccess-Magento网站下的Wordpress,带有多语言子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

tl;博士

我在www.example.com

我在www.example.com/wordpress

我还需要以下网址来提供相同的wordpress内容;

And I need the following urls to also serve that same wordpress content;

www.example.com/eu/wordpress
www.example.com/gb/wordpress

P.S .:我知道与此存在重复的内容问题,请忽略该问题

问题是:最好的方法是什么?

The question is: What's the best way to do that?

完整故事

我有一个使用> 2位语言代码子目录技术的Magento多商店网站.

我在自己的子目录中有一个Wordpress安装.

I have one Wordpress installation in it's own subdirectory.

app
downloader
errors
eu/ - symlinks for the € Euro store
gb/ - symlinks for the £ UK store
includes
js
lib
media
shell
wordpress/ - The Wordpress install
var

我需要所有商店都可以使用Wordpress博客,以便他们用户可以使用其语言环境/币种停留在商店中.

I need the Wordpress blog to be available from all stores so they user stays in the store with their locale/currency.

我尝试过的事情

使用这些堆栈中的答案;

Using the answers in these Stacks;

带有子目录的htaccess多语言站点,以及默认301

按htaccess规则使用多语言进行无尽重定向循环

我已经尝试过,但是不幸的是我对.htaccess和虚拟主机问题感到恐惧

I've made attempts but unfortunately I am terrible with .htaccess and vhosts problems

通过虚拟主机文件

Via the vhosts file

<VirtualHost *:80>
    ServerName www.example.com/eu/wordpress/
    ServerAlias www.example.com/wordpress/
    DocumentRoot /var/www/vhosts/www.example.com/public/wordpress
</VirtualHost>

<VirtualHost *:80>
    ServerName www.example.com/gb/wordpress/
    ServerAlias www.example.com/wordpress/
    DocumentRoot /var/www/vhosts/www.example.com/public/wordpress
</VirtualHost>

通过Wordpress htaccess

Via the Wordpress htaccess

RewriteCond %{REQUEST_URI} !^/(eu|gb )/wordpress(/|$) [NC]
RewriteRule ^(.*)$ wordpress/$1 [R=301,L]

通过Magento .htaccess

Via the Magento .htaccess

RewriteCond %{REQUEST_URI} ^/eu/wordpress/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/gb/wordpress/(.*)$ [OR]
RewriteRule ^/wordpress/.*$ - [L]

推荐答案

首先,wordpress不需要虚拟主机,每个域和/或子域只需要一个虚拟主机.您的虚拟主机应该看起来像这样(我假设您已经在magento商店中拥有类似的虚拟主机):

Firstly, you don't need vhosts for wordpress, you need only one vhost per domain and/or subdomains. Your vhost should look something like this(which I assume that you already have a vhost similar to this for your magento shop):

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com

    DocumentRoot /var/www/vhosts/www.example.com/public

    <Directory "/var/www/vhosts/www.example.com/public">
        # allow .htaccess files to override all directives
        AllowOverride All
    </Directory>
</VirtualHost>

现在,您只需要修改magento的 .htaccess (/var/www/vhosts/www.example.com/public/.htaccess),并添加以下规则:

Now, you just need to modify magento's .htaccess(/var/www/vhosts/www.example.com/public/.htaccess), and add the following rules:

<IfModule mod_rewrite.c>
    RewriteEngine on

    # rewrite rule to redirect
    # eu/wordpress  -> /wordpress/
    # eu/wordpress/ -> /wordpress/
    # gb/wordpress  -> /wordpress/
    # gb/wordpress/ -> /wordpress/
    RewriteRule ^(eu|gb)/wordpress/?$ /wordpress/ [R=301,NC,L]

    # ... continue here with magento's rewrite rules ...
</IfModule>

这篇关于.htaccess-Magento网站下的Wordpress,带有多语言子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆