Log in

View Full Version : URL not found Page



Jas
04-07-2007, 12:24 AM
Is there a script that sends a user to an assigned page if the URL they want within a site is not found (Preferable Javascript or PHP)? I have seen it many times, but don't know how to do it. . .

thetestingsite
04-07-2007, 12:28 AM
Make a file called .htaccess, and place that at the root directory. In this file, place the following:



ErrorDocument 404 http://www.yoursite.com/custom_page.html


Hope this helps.

Twey
04-07-2007, 09:57 AM
Only under Apache or some others.

djr33
04-07-2007, 02:14 PM
Also, be careful about doing this manually on some webhosts.
Some use cpanel or other site control setups that will allow for you to change/control this from there, so look into that if you have a hosting account rather than your own server. If there is no option, though, this should work.

Jas
04-07-2007, 05:01 PM
Make a file called .htaccess, and place that at the root directory. In this file, place the following:

called Something.htaccess of .htaccess.something or just .htaccess?

thetestingsite
04-07-2007, 05:02 PM
Just .htaccess, nothing more or less.

Jas
04-07-2007, 05:06 PM
Thanks!

It seems ninety percent of the help I get comes from you, now-a-days thetestingsite. Appreciate it!

djr33
04-07-2007, 10:41 PM
A file starting with just a dot is usually a system file. This is a very specific file that is designed to control how your site is served, and there are many more things that can be included in the file.
Also be careful to not override an existing .htaccess file. (You may not be aware of it, as it may have been set up automatically.)

In a .htaccess file, you can just add or remove lines to change behavior. You can do so with this line and just add it to your existing file. Or, perhaps, you already have it linking to a default page, and you can instead change the existing line.