We recently decided to use WordPress as our front page instead of the forum, so we moved things around and installed WordPress in the root directory of the website, but unfortunately the forum (/forum) (which also relies on its own .htaccess rules) is now broken because of the .htaccess (in the root directory of the website)

The website structure is:

  • https://www.example.com/ (WordPress)
  • https://www.example.com/forum/ (IPB forum)

But as you can see if you try logging into the forum, it throws you back to a "Not found page" on WordPress.

The .htaccess file which we use in the root is:

<IfModule php7_module>
  php_flag display_errors On
  php_value max_execution_time 90
  php_value max_input_time -1
  php_value max_input_vars 1000
  php_value memory_limit -1
  php_value post_max_size 64M
  php_value session.gc_maxlifetime 1440
  php_value session.save_path "/var/cpanel/php/sessions/ea-php70"
  php_value upload_max_filesize 2G
  php_flag zlib.output_compression On

<IfModule mime_module>
   AddType application/x-httpd-ea-php71___lsphp .php .php7 .phtml

# BEGIN WordPress
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
# END WordPress

and the .htaccess file we use in /forum is:

<IfModule mod_rewrite.c>
  Options -MultiViews
  RewriteEngine On
  RewriteBase /forum
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /404error.php [L,NC]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]

How can we stop the rewrite rules in the .htaccess in the root directory affecting sub directories?

Help would be much appreciated as we can't seem to get it working, we have tried everything.


As part of this "moving things around", you presumably moved the forum from the document root into the /forum subdirectory?

How can we stop the rewrite rules in the .htaccess in the root directory affecting sub directories?

They are not. At least it's not the mod_rewrite directives in the root directory that's the problem. By default, the mod_rewrite directives in the subdirectory completely override the mod_rewrite directives in the parent (root) directory. The "problem" is the mod_rewrite directives in the /forum/.htaccess file.

In your /forum/.htaccess file you need to remove the slash prefix on the RewriteRule substitution. For example, the following:

RewriteRule . /index.php [L]

Should read:

RewriteRule . index.php [L]

And the same for the /404error.php substitution.

Otherwise, the RewriteBase /forum directive will be ignored and you are going to rewrite to the filesystem root, ie. back to your new WordPress install - which appears to be what you are seeing.

  • 1
    Thanks, that was such a simple fix, everything is working fine now :) – SM9 Jan 11 '18 at 17:06

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.