Jump to content

Removing/transfering Addon Domain Folder From Main Domain


Recommended Posts

Posted

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.

Posted

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.
Posted (edited)

Try something like this:

 

/home/mlex/public_html/example.com/.htaccess

RewriteEngine on
RewriteCond %{HTTP_HOST} !\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
Edited by Krydos
removed domain
Posted

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.

Posted

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...