3

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
Swen
  • 767
  • 1
  • 9
  • 31

2 Answers2

2

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

Aamir Rizwan
  • 827
  • 5
  • 13
  • 34
1

Try adding this to the htaccess file in the document root of your main domain:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?maindomain\.com$ [NC]
RewriteRule ^/?addondomain - [L,F]

If you want to redirect it somewhere instead of returning a 403 forbidden, change the last line to something like:

RewriteRule ^/?addondomain http://www.maindomain.com/ [L,R]
Jon Lin
  • 142,182
  • 29
  • 220
  • 220
  • I tried adding this to the htaccess file in my root folder but it didn't seem to work for me. I updated my question to include the htaccess file I'm using. – Swen Apr 17 '13 at 23:15