I have hosted many domains at my GoDaddy hosting. There 'example.com' is my primary domain and its WordPress files are in folder 'web_example' situated at root. There is a .htaccess file at root to configure root.
Around 20 secondary domains are having each one folder at root. Few are WordPress and other are non-Wordpress folders. Few secondary websites are having their .htaccess file to configure them.
I wanted to restrict access of secondary websites through primary domain URL. But my .htaccess file situated at root, only able to prevents folders that are non-WordPress and not having their individual .htaccess file.
The file .htaccess at root is something like follows:
# Restrications
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ [NC]
RewriteCond %{REQUEST_URI} ^/sec_domain_1_folder/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/sec_domain_2_folder/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/sec_domain_3_folder/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/sec_domain_4_folder/(.*)$
RewriteRule ^(.*)$ - [L,R=404]
</IfModule>
# next lines are for rewrite to HTTPS
# next lines are for primary domain mapping to WordPress 'web_example' folder
The file .htaccess in sec_domain_2_folder is like follows:
# 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
Now, when I open "example.com/sec_domain_1_folder", it's redirects to "example.com/.errordocs/404.html". The same thing happening for "example.com/sec_domain_2_folder". Here both these folders are non-WordPress and also not containing .htaccess file in their folders.
But problem arising with URLs 'example.com/sec_domain_2_folder' and 'example.com/sec_domain_3_folder'. Here both these folders are WordPress and containing their .htaccess files. They are opening the URLs successfully with their respective wordpress theme and 404 error.
I want that all URLs like 'example.com/secondary_domain_folder' should redirect to hosting default error page "example.com/.errordocs/404.html".