mlex Posted September 27, 2017 Posted September 27, 2017 I was wondering if there's a way to forbid somehow an access to the addon domain when accessed through the first, main domain(like firstdomain.com/addondomain.com), but allow access through a regular access(addondomain.com)? Or perhaps there is a way to transfer my addon domain to the same level as my main domain, so it won't be a folder inside of my main domain? I tried to google for some .htaccess solution, but without any positive results. There's also another way I thought about, but it's ugly...I thought of using my main domain as dummy domain, and then use addon domains for main and addondomain. But again, it's ugly and more a way of fooling myself instead of a finding true solution.
Krydos Posted September 27, 2017 Posted September 27, 2017 Or perhaps there is a way to transfer my addon domain to the same level as my main domain, so it won't be a folder inside of my main domain?Addon domains are for sites that are separate from your other domains in a subdirectory. Use an alias if you want your new domain to show the same content as your main domain.
mlex Posted September 27, 2017 Author Posted September 27, 2017 Yeah, I'm aware of it.It's just I don't want to allow users to access my addon domain through subdirectory
Krydos Posted September 27, 2017 Posted September 27, 2017 (edited) Try something like this: /home/mlex/public_html/example.com/.htaccessRewriteEngine on RewriteCond %{HTTP_HOST} !\.example\.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301] Edited September 27, 2017 by Krydos removed domain
mlex Posted September 27, 2017 Author Posted September 27, 2017 Thanks, but this is a redirection. I guess there's no way around it to deny access from main domain.
Krydos Posted September 27, 2017 Posted September 27, 2017 If you don't want to redirect, but just deny then use a 403 forbidden instead of a 301 redirect. At this point I'm not really sure what you want.
mlex Posted September 27, 2017 Author Posted September 27, 2017 (edited) Thanks Edited September 27, 2017 by mlex
mlex Posted September 28, 2017 Author Posted September 28, 2017 In case someone will need a solution for this: Assuming example.com is your addon domain name, create or add below to your .htaccess file located at:public_html/example.com/.htaccess RewriteCond %{REQUEST_URI} ^/example\.com [NC] RewriteRule ^(.*)$ %{REQUEST_URI}/%1\? [L,R=403]Use [L,R=404] to make this more real. It will output your 404 error page as it normally would do if your example.com folder wouldn't exist. For more info:http://httpd.apache.org/docs/current/mod/mod_rewrite.htm
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now