Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- 404 htaccess Multi-Install


jdMorgan - 4:00 pm on Dec 16, 2010 (gmt 0)


ErrorDocument defines the handler filepath for all 404s in the URL-space that maps to the .htaccess or config file at hand. It does not 'select' the URLs to be 404'ed.

So what you need is code that forces a 404 if the URL-path is requested 'from the wrong hostname'.

Either of two methods could be used, one required by Apache 1.x but usable on all versions (and therefore more-portable across possible future hosting accounts), and the other specific to Apache 2.x:

Apache 1.x or 2.x:

# If widget/ URL-path requested from non-example-B.com host, rewrite to non-existent filepath to force 404 response
RewriteCond %{HTTP_HOST} !^example-B\.com
RewriteRule ^widget/ /filepath-which-is-known-not-to-exist.lmth [L]

Apache 2.x:

# If widget/ URL-path requested from non-example-B.com host, force 404 response
RewriteCond %{HTTP_HOST} !^example-B\.com
RewriteRule ^widget/ - [R=404,L]

Jim


Thread source:: http://www.webmasterworld.com/apache/4242621.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com