404 Not Working?


I am extremely new to .htaccess, and I have a lot of questions.
As for this post, though, I only have one.

How can I create a 404 redirect in .htaccess?
I’ve attempted the ErrorDocument 404 somefilehere.php, but it doesn’t work.

Here’s my code:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /Bloody/

RewriteRule ^([^.]+)$ index.php?title=$1

A basic URL would look like mydomain.com/Bloody/Page+Title.
I want to make it so that if you go to mydomain.com/Bloody/Page+Title/Additional+Stuff+Here, it will redirect to a 404.
For the time being, it just displays a white page with all of my text on it, and it screws up the file path for my css file.

So really, if an additional slash is added to the URL, I want it to go to a 404 page.

You can just put something like this in you .htaccess:

ErrorDocument 404 /my404.php

Apparently it’s important to make sure the 404 page is at least 4k in size, as older IEs will otherwise display a default 404 message.

Thank you! :smiley:


Actually, the correct COMMON use of ErrorDocument is ErrorDocument {numeric_code} {ABSOLUTE_URI/URL}. The size of the Redirection is irrelevant as it can actually be a message, too, but I’ll leave that to your own research.

You can also use mod_rewrite, too, but that’s apparently not what you were trying to do (because you don’t need the POWER of mod_rewrite).