subdirectory index.php is not working

All you should need to do is make sure the appropriate DirectoryIndex is set. For example, at the top of your .htaccess file:

DirectoryIndex index.php

This instructs mod_dir to try to serve index.php when requesting a directory, eg. /sq/first/.

If you are requesting URLs/directories that don’t already contain the trailing slash, as in your example: /sq/first, then you need to make sure that DirectorySlash On (also part of mod_dir) is also set (although this is the default setting). For example:

DirectoryIndex index.php
DirectorySlash On

However, you should really be requesting the /sq/first/ (with a trailing slash), as otherwise mod_dir issues a 301 redirect in order to append the trailing slash – which is an additional round trip to your server.


RewriteBase /
:
RewriteBase /sq/

Aside: Ideally, you should never include more that one RewriteBase directive in your .htaccess file. Since WordPress is installed in the document root, then RewriteBase should probably be set to the document root, ie. RewriteBase /. If you have more than one RewriteBase directive then the last one wins and controls the entire file. So, in this example, RewriteBase is set to /sq/, not /. However, in your .htaccess file, RewriteBase is not actually being used anyway. (You also have it in the middle of a rule block – which doesn’t make much sense – in fact, I’m surprised that doesn’t result in an error?)


UPDATE: So, in summary:

DirectoryIndex index.php
DirectorySlash On

ErrorDocument 401 default

# 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]    

#----- START DAP -----
RewriteCond %{REQUEST_FILENAME} -f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} (.*)/wp-content/uploads/(.*) 
RewriteCond %{REQUEST_FILENAME} !(.*)(\.php|\.css|\.js|\.jpg|\.gif|\.png|\.txt|\.ico|\.jpeg)$ 
RewriteRule (.*) /dap/client/website/dapclient.php?dapref=%{REQUEST_URI}&plug=wp&%{QUERY_STRING}  [L] 
#----- END DAP -----

</IfModule>
# END WordPress

You should avoid adding your own custom code between the # BEGIN WordPress and # END WordPress comment markers as WP itself might overwrite this in a future update.

I removed the section you had to “exclude” certain directories. That shouldn’t do any harm, however, it is also unnecessary, given the existing WordPress mod_rewrite directives. WordPress (the mod_rewrite directives above) already excludes physical directories from being routed through WP.