1

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:

enter image description here

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]    
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
    Jul 4 '19 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/. Jul 4 '19 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
    Jul 4 '19 at 23:10
  • Added the info. Jul 4 '19 at 23:22
  • You are using WordPress multisite - is that required?
    – MrWhite
    Jul 4 '19 at 23:46
0

I assume your preferred hostname is www.example.com (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.com (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\.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]    
2
  • Exactly what I was looking for, and much simpler than I would've thought! Thank you very much for your quick and extensive reply! Jul 5 '19 at 0:09
  • You're welcome. I've reordered some of the directives as there was some duplication between the two .htaccess files. For instance, both Wolf CMS and WordPress avoid rewriting static resources.
    – MrWhite
    Jul 5 '19 at 0:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.