.htaccesssubdirectoryaddon-domain

Disable access to addon domain through maindomain.com/addondomainfolder


I want to disable access to the folder of my addon domain using .htaccess but I can't seem to figure it out.

My folder structure is like this:

root/maindomain (www.maindomain.com/maindomain)
root/addondomain (www.addondomain.com)

I want to disable access to my addon domain through the www.maindomain.com/addondomain url.

How would I do this?

My htaccess file in the root directory:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?swen\.me.uk$ [NC]
RewriteRule ^/?creepypastaindex http://www.creepypastaindex.com/ [L,R]

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?swen.me.uk$
RewriteCond %{REQUEST_URI} !^/swen/
RewriteRule ^(.*)$ /swen/$1

Solution

  • This should do. You have to escape both dots.

    RewriteEngine On
                RewriteCond %{HTTP_HOST} ^(www.)?swen\.me\.uk$ [NC]
                RewriteCond %{REQUEST_URI} ^/creepypastaindex/(.*)$
                RewriteRule ^(.*)$ - [L,R=404]
    

    Source