Forum Moderators: phranque
But my issue is that when any[one] opens www.domain1.com/domain2/index.html... we can see the /domain2/index.html page which I wish to restrict. I want to keep the 2 websites completely separated and dont want to allow users to see domain2 from domain1 and vice versa. Please help!
Sorry if this question has been asked before, but I havent been able to figure out how to use .htacess file yet, so would be glad if some[one] could explain how the required configuration is achieved.
[edited by: jdMorgan at 12:59 am (utc) on Aug. 21, 2007]
[edit reason] English only, no 'L33T' please. [/edit]
If "this" is requested, go "there" for the content.
This is a common question. Check the threads here for the last week or so.
Try modifying some example code from one of those threads, and then post back here with what you have done and what problems you are having.
So I dont want the user/crawler to understand that both of these domain are related to each other. Got my point? Thats the reason I want to do a block on the folder, when accessing from www.domain1.com
What is [F]? and how to use it? Could please help me out with some examples?
If the goal is to "seem unrelated," then a 403-Forbidden response would be somewhat "out of character" for a "normal" server. And especially if that were the only circumstance under which the server returned a 403.
I'd recommend rewriting the subfolder request to a non-existent filepath, even literally like this:
# if domain1.com or www.domain1.com
RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com
# rewrite /domain2/<anything> to nonexistent filepath
RewriteRule ^domain2/ /file-which-does-not-exist.html [L]
The above assumes that you already have other working mod_rewrite rules in the file. If not, some additional "setup" is required.
Jim
# Enable Symbolic Links
Options -Indexes +FollowSymLinks # Enable Basic Rewriting
RewriteEngine on
# cache images and flash content for one month
<FilesMatch ".(flv¦gif¦jpg¦jpeg¦png¦ico¦swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
# cache text and css files for one week
<FilesMatch ".(css¦pdf¦txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
# secure htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
# if domain1.com or www.domain1.com
RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com
# rewrite /domain2/<anything> to nonexistent filepath
RewriteRule ^domain2/file-which-does-not-exist.html [L]
This is what my .htaccess file looks like... Im still able to view domain2 from www.domain1.com/domain2
Please help!
So, you may need to move the rule into .htaccess in domain2's subdirectory, and modify it to work in that location:
# Enable Symbolic Links
Options -Indexes +FollowSymLinks
#
# Enable Basic Rewriting
RewriteEngine on
#
# if requested via domain1.com or www.domain1.com
RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com
# rewrite /domain2/<anything> to nonexistent filepath
RewriteRule .* /file-which-does-not-exist.html [L]
Jim
Anyways, I think this solution of showing a file not found page is perfectly suiting the need and thanks a lot for all your support. It is working perfectly when I add the .htaccess to the subdirectory named domain2.
Thanks again for your support and co-operation!