So I have an apache server with subdomains with subdirectories. I turn my directories into subdomains. So instead of example.site.com/mycoolsite it’s mycoolsite.example.com. Or in other words I turn /var/www/mycoolsite into /var/mycoolsite. I do this with the .htaccess file with the below code.
RewriteCond %{HTTP_HOST} ^mycoolsite.site.com$ [NC]
RewriteCond %{REQUEST_URI} !^/mycoolsite/
RewriteRule ^(.*)$ /mycoolsite/$1 [L]
Great. Now it turns the directory into the subdomain. The problem now is that .htaccess can’t reference the ErrorDocument I setup for my original subdomain. I can go to example.site.com/mycoolsite/aNonExistantDirectory/ and get the proper 404 I have setup, but when I try mycoolsite.site.com/aNonExistantDirectory/ I get the basic server 404 error page, not the one I have setup. Both are on the same server. To get around the problem, I can make a copy of the error documents and put them inside the /mycoolsite/ directory but I’m hoping I can simply reference the original error documents.
The problem is, I don’t know how to reference the error documents in /var/www/error/ to /var/www/mycoolsite/ I’ve tried:
ErrorDocument 404 ../error/index.php?p=404
ErrorDocument 404 /www/error/index.php?p=404
ErrorDocument 404 www/error/index.php?p=404
ErrorDocument 404 error/index.php?p=404
ErrorDocument 404 /error/index.php?p=404
None of those work. When try it without the first / or preceding .. it will display the error document line on the page. I’m stumped. I hope I included enough information, but if not, let me know.
I don’t think apache lets you reference files outside of the current document_root. It’s a security thing. What you can do is create a dummy php file that just contains a
include(../error/index.php)