Page 1 of 1
preventing from a use to get to a 404 page
Posted: Tue Dec 09, 2003 1:37 am
by pelegk2
i am running php over apache
is there a way to prevent from a user from hetting to unexisting page?
for exampl
if the user type by mistake :
page1.ph
instead of page1.php
i want him in this case to go to a certin page!
how do i do that?
thanks in advance
peleg
Posted: Tue Dec 09, 2003 2:07 am
by infolock
i'm assuming you are using Apache..
Create a file called .htaccess in the root directory of the server (the one you refer to as '/') and enter your error handlers in the following format, one per line:
ErrorDocument [3-digit code] [action]
For example, you can point to a custom 404 page like this:
ErrorDocument 404 /errors/custom404.html
You can also simply have it display some other text:
ErrorDocument 404 "Sorry, this page doesn't exist.
Make sure you begin the text with a quote (").
Windows users have reported problems creating .htaccess files. Create a file named 'htaccess.txt', FTP it to your web host, and then rename it to .htaccess.
You can even make your 404 errors more friendly for international visitors by displaying a page in their own language. Check out this Apache article.
Just make sure you create a 404.htm page that tells the user the page could not be found,a nd then insert it as described above.
ok i understood almost everythin
Posted: Tue Dec 09, 2003 2:20 am
by pelegk2
i didnt execlly understand ho to call execlly the file name?
the apache server it on my pc so i dont have poblem to access it
so how execly do i call the fil "htaccess'" the exclly file name?
thanks alot
peleg
Posted: Tue Dec 09, 2003 2:46 am
by Weirdan
Posted: Tue Dec 09, 2003 2:46 am
by Nay
You just drop the file in the directory you want to configure. It's not a filename by the way since it's not -> .htaccess.txt. Be careful when you save, if you use notepad, when saving put file type to "all files".
-Nay
i dint know why it isnt working
Posted: Tue Dec 09, 2003 4:41 am
by pelegk2
i hae opened a file called :
then i wrote in it :
Code: Select all
<?php
ErrorDocument 404 "Sorry, this page doesn't exist.
?>
and still nothin
and even estarted the derver
and putted the file in the root
any idea?
i even tried to make changes at
Posted: Tue Dec 09, 2003 4:48 am
by pelegk2
conf/httpd.conf
and it didnt help:(
what to do??
Posted: Tue Dec 09, 2003 5:05 am
by jollyjumper
Hi Peleg,
Open notepad.
Paste these 4 lines in it:
ErrorDocument 500 /error.htm
ErrorDocument 404 /error.htm
ErrorDocument 401 /error.htm
ErrorDocument 403 /error.htm
Select File, Save as
Select All files in the Save file dialog box.
Type .htaccess and press the save button.
Upload the .htaccess file to the root folder of your webserver.
Create a file called error.htm and upload this in the root folder of your webserver.
Call a file that doesn't exist and it should show the content of your self made error.htm
Hope this helps you.
Greetz Jolly.
still isnt working
Posted: Tue Dec 09, 2003 5:25 am
by pelegk2
maybe something else ineed to define to so i will work?