Forum Moderators: phranque
ErrorDocument 403 "<center><h1>Access is Forbidden.</h1></center> in my htaccess file. ErrorDocument 403 "<center><h1>Access is Forbidden.</h1></center>is more likely to serve up a 500 than 404 or 403. The htaccess doesn't create pages, the html needs to actually be on a real page on your site, then you tell the server where to find it:
ErrorDocument 403 /403.html In /addon_folder/.htaccess:
RewriteEngine on
#Redirect to example.com if request was made to www.addon.example.com or addon.example.com
RewriteCond %{HTTP_HOST} ^(www\.)?addon\.example\.com [NC]
RewriteRule (.*) http://example.com/$1 [R=301,L]
In example.com/.htaccess:
# If [i]direct client request[/i] for www.example.com/addon or example.com/addon, redirect back to addon domain
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /addon/?
RewriteRule ^addon/?(.*)$ http://addon.com/$1 [R=301,L]
Checking THE_REQUEST ensures that /addon was directly requested by the client, and is not the result of the internal rewrite used to map addon.example.com to /addon. If the request was direct, we want to redirect it. If the request was the result of the internal rewrite, we do not want to redirect it, because that would break the addon subdomain.
You really have three choices here, and you should think about what you want to do. If you get a request for example.com/addon/ or addon.example.com, you can:
Redirect to addon.com
Redirect to example.com
Deny access -- Return 403-Forbidden
The code above shows one example for each of the first two choices in the list.
The choices you make will depend on whether or not your addon-domain folders have already been "exposed" to search engines, and how well you test your sites. Obviously, you don't want to return 403-Forbidden unless the folder paths have never been published, and you are sure that you will never link to them accidentally. All-in all, I think I prefer the rule "If an incorrect URL mentions "addon", correct it by redirecting to addon.com".
I want them to receive a 404 from www.example.com. I have ErrorDocument 403 "<center><h1>Access is Forbidden.</h1></center> in my htaccess file.
All of the examples I've found except two show 301 rewrites.
We all know I can get to addon domain three ways, via: 1) www.addon.com 2) addon.example.com 3) (www).example.com/addon.
And please don't provide code unless you've actually tested it and it works.kind of impossible - only you can test.
It would be a miracle if someone can give me a solution that actually works.