相同域但不同子目录上的多个CMS(多站点WordPress+wolfcms)的HTAccess文件

时间:2019-07-04 作者:the.michiel

感谢您阅读本文!

我正在建立的网站用于2003年以来举行的年度研讨会。所有这些网站仍然在线,应该保持在线。

从2003年到2012年,网站没有使用任何cms,可以通过/$year子目录访问。(见以下结构)

自2012年起,子目录从wolfCMS中生成。从今年起,我们希望切换到wordpress。(见以下结构)

应如何配置htaccess文件以使其工作,以便用户从研讨会的早期版本重定向到wolfcms,并从今年起重定向到wordpress站点?谢谢

网站结构:

enter image description here

htaccess of wolfCMS in ~/public\\u html/文件夹:

#Setting Wolf CMS requirements
#On some server configurations you may need to comment out one or more of
#the three lines below due to server limitations.

php_flag magic_quotes_gpc off
AddDefaultCharset UTF-8
Options -Indexes +FollowSymLinks

# Setting rewrite rules

<IfModule mod_rewrite.c>
RewriteEngine On
# Set next line to your Wolf CMS root - if not in subdir, then just /
RewriteBase /

RewriteCond %{http_host} !^www.root.nl [NC]
RewriteRule ^(.*)$ http://www.root.nl/$1 [L,R=301]

# Rules to allow install sequence to test for mod_rewrite support
RewriteRule ^wolf/install/index.html$ wolf/install/index.php?rewrite=1 [L,QSA]
RewriteRule ^wolf/install/index.php$ wolf/install/index.php?rewrite=1 [L,QSA]
RewriteRule ^wolf/install/$ wolf/install/index.php?rewrite=1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
# Main URL rewriting.
RewriteRule ^(.*)$ index.php?WOLFPAGE=$1 [L,QSA]

</IfModule>    
htaccess of wordpress in ~/public\\u html/wordpress/文件夹:

RewriteEngine On
RewriteBase /wordpress/

RewriteCond %{HTTP_HOST} root.nl/wordpress/$1 [NC]
RewriteRule ^(.*)$ http://root.nl/$1 [R=301,L]

#RewriteRule ^index\\.php$ - [L]


# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\\.php)$ $2 [L]
# RewriteRule . /wordpress/index.php [L]    

1 个回复
最合适的回答,由SO网友:MrWhite 整理而成

我想您首选的主机名是www.example.com (www.root.nl) - 这需要对两个站点保持一致。(目前,您的Wolf CMS似乎更受欢迎,而您的WordPress指令正在重定向到example.com (否www).

这还假设您的所有URL都以4位数的年份作为前缀。即:

  • /2003/2012 - 静态站点/2013/2018 - 沃尔夫CMS/2019 以后-WordPress可在.htaccess 文档根目录中的文件(public_html 目录)并删除.htaccess 中的文件/wordpress 子目录:

    #Setting Wolf CMS requirements
    #On some server configurations you may need to comment out one or more of
    #the three lines below due to server limitations.
    
    php_flag magic_quotes_gpc off
    AddDefaultCharset UTF-8
    Options -Indexes +FollowSymLinks
    
    # Setting rewrite rules
    RewriteEngine On
    
    # Set next line to your Wolf CMS root - if not in subdir, then just /
    # NB: You can only set the RewriteBase once in any one .htaccess file
    RewriteBase /
    
    # Canonical redirect
    RewriteCond %{http_host} !^www\\.example\\.com$
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    
    # Prevent further processing if request maps to an actual file
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} -l
    RewriteRule ^ - [L]
    
    # Rules to allow install sequence to test for mod_rewrite support
    # >>> ARE THESE STILL REQUIRED?
    #RewriteRule ^wolf/install/index.html$ wolf/install/index.php?rewrite=1 [L,QSA]
    #RewriteRule ^wolf/install/index.php$ wolf/install/index.php?rewrite=1 [L,QSA]
    #RewriteRule ^wolf/install/$ wolf/install/index.php?rewrite=1 [L,QSA]
    
    # Wolf CMS front controller
    # Years 2013-2018 only - checks for this in the URL before rewriting
    RewriteRule ^(201[345678]/.*) index.php?WOLFPAGE=$1 [L,QSA]
    
    #
    # When the request does not match above its falls through to WordPress...
    #
    
    RewriteRule ^wordpress/index\\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\\.php)$ $2 [L]
    RewriteRule . /wordpress/index.php [L]    
    

相关推荐

访问WordPress MultiSite中每个角色的插件

我创建了一个多站点网站。网站上创建了几个使用aam插件的角色:SpecialprofessionalAnd。。。我希望在该网站上注册的用户创建一个网站,并将我允许他们适应其角色的插件分配给他们。换言之,对于具有特殊角色的用户的角色,在创建网站时,Woocomece插件会自动启用,但对于注册了专业角色的用户,该插件不会处于活动状态。请引导我。