RSS

Forum | Using .htaccess for 404 pages

This Forum is Currently Locked – Access is Read Only
You must be logged in to post
Search Forums:


 






Using .htaccess for 404 pages

UserPost

9:04 PM
Mar 28, 2010


acousticsam

Member

posts 46

1

I realized that my host's default 404 pages were filled with spammy links, so I figured I should make up a custom 404 page for my websites.

I followed the directions from my host's support pages, but I don't have it quite right.

In my home folder, I have an .htaccess file with the following code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /404.php


It works fine if someone goes to http://www.mysite.com/wrongpage, but if someone goes to http://www.mysite.com/subdirec…../wrongpage, all the styling of the 404 page is gone. Plus, none of the links work because it's trying to go relative to the subdirectory, when it should be going relative to the site root…

What am I doing wrong?

10:57 AM
Mar 31, 2010


acousticsam

Member

posts 46

2

Fixed. All href and src attributes need to be absolutely linked. Who knew?