Custom Error Page for Subdomain

Status
Not open for further replies.

techairlines

x10 Flyer
Community Support
Messages
2,867
Reaction score
165
Points
63
Hi. I just created a Custom 404 Error page here: http://www.techairlines.com/404.shtml. I added ErrorDocument 404 http://www.techairlines.com/404.shtml to my .htaccess file, however, this doesn't seem to work on my subdomain of downloads.techairlines.com. Any non existant page would just display index.php.

On the other parts of my site, I realize it wouldn't work because its Wordpress. However, I would like to know how to get it to work on the downloads subdomain.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
place a copy of 404.shtml in the downloads directory
Note the slash / in front of the file name in .htaccess in the downloads directory

ErrorDocument 404 /404.shtml
 

techairlines

x10 Flyer
Community Support
Messages
2,867
Reaction score
165
Points
63
Yep. I tried doing that. Apparently any non-existant page on the subdomain loads the index file although the URL is still the non-existant URL. The only line in my .htaccess file is

ErrorDocument 404 /404.shtml
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Sounds like you might have a rewrite rule somewhere that looks like

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /index.html [L]

which redirects all missing pages to the index. Hence Apache never thinks the page is missing, hence never uses the 404 document.
 
Last edited:

techairlines

x10 Flyer
Community Support
Messages
2,867
Reaction score
165
Points
63
I have something like that in my home directory that redirects /mail (with or without www) to Google Apps Mail. All my other .htaccess files have nothing but one line.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^techairlines.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.techairlines.com$
RewriteRule ^mail$ "https\:\/\/mail\.google\.com\/a\/techairlines\.com" [R=301,L]

The above is in my public_html .htaccess. Thats the only thing other than Wordpress things there.
I'm not sure if this has anything to do with the lines you mentioned.

The .htaccess file in all subdirectories and the root of the downloads directory has nothing but one line in them.

Even non existant files in the subdirectory "files" loads the index of the "downloads" folder anyway.
 
Last edited:

arizonapcrepair

New Member
Messages
35
Reaction score
0
Points
0
I forgot what it was, but I put a javascript redirect coding into the 404 error page box, and had it redirect to another page. Just type in some jibberish after my URL in my sig for an example.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Subdomains either use the rewrite engine or virtual hosts. Both of these will cause problems for error documents defined on the top domain. The apache configuration options for Wordpress are also probably causing problems. What else is in .htaccess?
 

techairlines

x10 Flyer
Community Support
Messages
2,867
Reaction score
165
Points
63
My .htaccess file in the root directory with Wordpress is this:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^techairlines.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.techairlines.com$
RewriteRule ^mail$ "https\:\/\/mail\.google\.com\/a\/techairlines\.com" [R=301,L]


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
Options All -Indexes

All my other .htaccess files like the one in the downloads directory is:

ErrorDocument 404 /404.shtml

I also put the error page in each directory.

I know that this won't work for Wordpress or my forum but it doens't seem to work anywhere. It loads the index instead.
 

adamparkzer

On Extended Leave
Messages
3,745
Reaction score
81
Points
0
Sounds like you might have a rewrite rule somewhere that looks like

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /index.html [L]

which redirects all missing pages to the index. Hence Apache never thinks the page is missing, hence never uses the 404 document.

This is your solution. You need to get rid of those lines of code if you want your custom 404 page to work. To my knowledge. the .htaccess file in the root directory also applies to subdirectories, so the .htaccess file that you copied and pasted above is causing the rest of your pages to follow the same rewrite condition.
 

techairlines

x10 Flyer
Community Support
Messages
2,867
Reaction score
165
Points
63
All right. Thanks. That works although it breaks Wordpress, but I guess thats another issue.
 
Status
Not open for further replies.
Top