Jump to content

Removing/transfering Addon Domain Folder From Main Domain


mlex

Recommended Posts

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.

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...