WP install in sub-dir white screen

If WordPress is installed in the directory /dir1/dir2 and the corresponding .htaccess file is also in that subdirectory, ie. /dir1/dir2/.htaccess, then the .htaccess file should look something like:

# 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]
</IfModule>
# END WordPress

This is very similar to the default WordPress .htaccess file, except I have commented out (removed) the RewriteBase directive and removed the slash prefix on the RewriteRule substitution (ie. what was /index.php is now index.php). This is important, as it allows Apache to add back the directory-prefix (the location of the .htaccess file) at the end of processing.

This obviously means that your URLs must contain the /dir1/dir2 directory prefix.


The two .htaccess files you posted don’t work because…

RewriteCond %{HTTP_HOST} ^(www.)?sub.domain.nl$
RewriteCond %{REQUEST_URI} !^/dir1/dir2/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /dir1/dir2/$1
RewriteCond %{HTTP_HOST} ^(www.)?sub.domain.nl$
RewriteRule ^(/)?$ dir1/dir2/index.php [L]

This is intended to be placed in the document root /.htaccess file with the intention of hiding the /dir1/dir2 subdirectory from the URL. By placing this in /dir1/dir2/.htaccess it just won’t do anything since the condition that checks the REQUEST_URI server variable will fail and the RewriteRule pattern ^(/)?$ will never match.

RewriteBase /sub.domain.nl/dir1/dir2/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /sub.domain.nl/dir1/dir2/index.php [L]

This would work if /sub.domain.nl was a directory on the filesystem (in the URL space), but it’s not; it’s the hostname, so it doesn’t make much sense. This allows the front page (homepage) to be displayed because the first RewriteRule prevents further processing. However, sub pages will likely result in an Apache generated 404 as /sub.domain.nl/dir1/dir2/index.php does not exist.

Note that, in this example, the RewriteBase directive does not do anything. The assigned RewriteBase only applies to relative path substitutions (ie. not absolute and not root-relative – starting with a slash). There are no relative path substitutions in this example.


UPDATE:

I changed the RewriteBase and RewriteRule to:

RewriteBase /internship/avans/
RewriteRule . /internship/avans/index.php [L]

The net result with my version (at the top) is the same. However, the RewriteBase directive is redundant and hardcoding the URL-path in this way is superfluous and less portable.

  • The RewriteBase /internship/avans/ directive is redundant in this example (and could be removed), since you have included the full URL-path in the RewriteRule substitution. The RewriteBase is only used when you have a relative path substitution (as mentioned above) in order to override the directory-prefix. So, to use the RewriteBase in this example you would write this as:

    RewriteBase /internship/avans/
    RewriteRule . index.php [L]
    
  • Hardcoding the URL-path naturally makes it less portable.

  • You only need to include the RewriteBase OR specify the full URL-path in the RewriteRule substitution (you don’t need to do both) if the .htaccess file is not in the application root directory of your WordPress install. eg. If WordPress is installed in /dir1/dir2, but the .htaccess is in the document root (in order to hide the WordPress application directory).


Bit of an aside, but… for the reasons mentioned above, the “default” WordPress .htaccess file is incorrect/misleading IMO:

# 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]
</IfModule>
# END WordPress

The RewriteBase / is not used here since the URL-path (simply /) is explicitly included in the RewriteRule substitution: /index.php. You don’t need both, and this seems to create a lot of confusion for users. In fact, you don’t need either if the .htaccess file is in the application root (which it is most of the time). By “application root” I’m referring to the directory where WordPress is installed, either the document root, or a subdirectory.

IMO, the “default” WordPress .htaccess file should be the one I’ve modified at the top of my answer (comment out the RewriteBase directive and remove the slash prefix) – which is what you are now using. This is far more portable and “just works” without modification regardless of where WordPress is installed (and you probably wouldn’t have needed to have asked your question, since the default file would have “just worked”).