Current location: Hot Scripts Forums » Other Discussions » Web Servers » .htaccess - creating custom 404's


.htaccess - creating custom 404's

Reply
  #1 (permalink)  
Old 05-18-08, 02:41 AM
undesired undesired is offline
Newbie Coder
 
Join Date: May 2008
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation .htaccess - creating custom 404's

What could I use to return the incorrect page typed (the wrong address), and display it, in the page.

How can I get the mistyped page only, also.





Example:


The page http://blah.com/blah.html is not here.


______________-
Example:

The page blah.html is not here.
Reply With Quote
  #2 (permalink)  
Old 05-18-08, 03:40 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Thread moved to Web Servers section (this has nothing to do with HTML)

And put this in your htaccess file:
Code:
ErrorDocument 404 /custom_404.html
Reply With Quote
  #3 (permalink)  
Old 05-18-08, 03:58 AM
undesired undesired is offline
Newbie Coder
 
Join Date: May 2008
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Sorry about the wrong location.

Also, I already know everything about .htaccess
I just don't know how to call the mistyped/incorrect url in the actual error document.

EDIT: And this is for specific directory htaccess.

ErrorDocument 404 /directory/404.html
Reply With Quote
  #4 (permalink)  
Old 05-18-08, 04:10 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Sorry, I misunderstood your question.

There are 2 ways to achieve this. You can either use Javascript:
javascript Code:
  1. <script type="text/javascript">
  2. document.write(window.location);
  3. </script>

Or PHP:
PHP Code:

<?php

echo htmlspecialchars(basename($_SERVER['REQUEST_URI']));
?>

Last edited by Nico; 05-18-08 at 04:22 AM.
Reply With Quote
  #5 (permalink)  
Old 05-18-08, 04:31 AM
undesired undesired is offline
Newbie Coder
 
Join Date: May 2008
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
I tried the js one before posting here .. It doesn't work, as it shows the url of the Error Document.

How can I get the typed url to stay the same?
Reply With Quote
  #6 (permalink)  
Old 05-18-08, 05:30 AM
undesired undesired is offline
Newbie Coder
 
Join Date: May 2008
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
No edit button? Anyways, I meant to say, I tried that before posting in the forum.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
sorting in a custom grid view painthu ASP.NET 1 05-17-08 02:51 PM
Difference between the user control and Custom server controls bhar ASP.NET 0 07-22-06 05:42 AM
[FOR SALE:] Fully Featured Custom Forum Nefarious Dev General Advertisements 0 06-27-06 05:08 PM
Custom IE Toolbar Development for your company or Website Chadhaajay General Advertisements 0 10-28-05 01:01 AM
creating .htaccess in windows secretman Perl 1 03-02-04 11:20 PM


All times are GMT -5. The time now is 01:28 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.