admin管理员组

文章数量:1422560

Thanks for reading this!

The website I am building is used for an annual symposium that is held since 2003. All those website are still online and should remain online.

From the year 2003 till the year 2012 websites were made without the use of any cms and can be access by going to the /$year subdirectory. (see structure below)

From 2012 onwards the subdirectories are generated from within wolfCMS. From this year onwards we would like to switch to wordpress. (see structure below)

How should the htaccess file(s) be configured to make it work so that users are redirected to the wolfcms from previous editions of the symposium and to the wordpress site from this year onwards? Thanks!

Website structure:

htaccess of wolfCMS in ~/public_html/ folder:

#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 ^(.*)$ /$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_html/wordpress/ folder:

RewriteEngine On
RewriteBase /wordpress/

RewriteCond %{HTTP_HOST} root.nl/wordpress/$1 [NC]
RewriteRule ^(.*)$ /$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]    

Thanks for reading this!

The website I am building is used for an annual symposium that is held since 2003. All those website are still online and should remain online.

From the year 2003 till the year 2012 websites were made without the use of any cms and can be access by going to the /$year subdirectory. (see structure below)

From 2012 onwards the subdirectories are generated from within wolfCMS. From this year onwards we would like to switch to wordpress. (see structure below)

How should the htaccess file(s) be configured to make it work so that users are redirected to the wolfcms from previous editions of the symposium and to the wordpress site from this year onwards? Thanks!

Website structure:

htaccess of wolfCMS in ~/public_html/ folder:

#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_html/wordpress/ folder:

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]    
Share Improve this question edited Jul 4, 2019 at 23:33 the.michiel asked Jul 4, 2019 at 21:54 the.michielthe.michiel 134 bronze badges 6
  • This depends on the URL structure. Specifically, the difference between the WolfCMS URLs and the WordPress URLs. Or are the two CMS in different subdirectories, and the subdirectory is part of the URL? If the later then you don't really need to do much. – MrWhite Commented Jul 4, 2019 at 22:31
  • Thanks for answering. The subdirectory is not part of the url, only the year is. So for years up to /2018/ the corresponding Wolfcms page should be loaded (this already works), but for /2019/ onwards, the corresponding wordpress page should be loaded (currently it is only accessible through ~/wordpress/. – the.michiel Commented Jul 4, 2019 at 23:06
  • Please add your current .htaccess file to your question. Presumably the intention is to have a single .htaccess in the public_html directory and no other .htaccess files in subdirectories? – MrWhite Commented Jul 4, 2019 at 23:10
  • Added the info. – the.michiel Commented Jul 4, 2019 at 23:22
  • You are using WordPress multisite - is that required? – MrWhite Commented Jul 4, 2019 at 23:46
 |  Show 1 more comment

1 Answer 1

Reset to default 0

I assume your preferred hostname is www.example (www.root.nl) - this needs to be consistent for both sites. (Currently your Wolf CMS seems to be favouring, whilst your WordPress directives are redirecting to example (no www).

This also assumes all your URLs are prefixed with a 4 digit year. ie.:

  • /2003 to /2012 - static site
  • /2013 to /2018 - Wolf CMS
  • /2019 onwards - WordPress

Try the following instead, in the .htaccess file in the document root (public_html directory) and remove the .htaccess file in the /wordpress subdirectory:

#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\$
RewriteRule (.*) http://www.example/$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]    

本文标签: htaccess file for multiple CMS39s (multisite wordpresswolfcms) on same domain but different subdirectories