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

1 Answer 1


After a lot searching, I have gotten the solution of this problem from the web.

A similar problem is discussed on this URL. And solution is given on 7th page of this URL.

  • what an horrible answer, but the least you can do is accept it.... Commented Aug 16, 2017 at 7:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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