• We should now be fully online following an overnight outage. Apologies for any inconvenience, we do not expect there to be any further issues.

Hrm... Re-Directing Error 404's?

Transition

Banned
Sep 8, 2001
2,615
0
0
Hello (once again),

Tonight is just plagued with problems.. Here's whats going on. I changed all my web pages (except my eCommerce section) to SHTML pages so i could dynamically modify my navigation bar. Now here's the problem, i have a lot of outside links pointing to places which are now dead... For example.. I have about 70 different links to this file...

http://www.hallusin8.com/small_instructions.htm

That file is no longer in my root directory, as i've removed it in favor of this SHTML stuff...... The file now resides as...

http://www.hallusin8.com/small_instructions.shtml

and of course that brings up an "HTTP 404 NOT FOUND"....

Ok since modifiying my .htaccess file worked so well to reference the shtml html htm files respectively, is there a way to automatically execute a function as such....

if document a is not found under extension a, look for extension b..

Or a real world application like this... the outside link brings someone to "http://www.hallusin8.com/small_instructions.htm" which doesn't exist. Is there a script to tell the server to look for the same fiel with just a "shtml" extension before giving the 404 NOT FOUND?

Any help is highly appreciated!

- RJ
 

Lars

Diamond Member
Jan 10, 2001
3,379
0
0

Transition

Banned
Sep 8, 2001
2,615
0
0
Ahh well - they'd be getting re-directed all over then since i do still have some .htm files around.. I need to be able to implement a system to check for another file extension before giving a 404.
 

Lars

Diamond Member
Jan 10, 2001
3,379
0
0
How does your htaccess look like?
Sometimes hosts override the 404 error redirection and you need to set it up using your web control panel.

edit: btw, very nice site (layout, colors)
 

Transition

Banned
Sep 8, 2001
2,615
0
0


<< How does your htaccess look like?
Sometimes hosts override the 404 error redirection and you need to set it up using your web control panel.

edit: btw, very nice site (layout, colors)
>>



Thanks for the compliements. :D

This is how my .htaccess file looks:
DirectoryIndex index.shtml index.html index.htm
ErrorDocument 404 http://www.hallusin8.com/small_instructions.shtml

hrm.... There's got to be a way to tell the server to look for secondary file extensions before pulling the 404
 

Lars

Diamond Member
Jan 10, 2001
3,379
0
0
put this on top:

RewriteEngine On

then it should redirect it.

here are some more information about htaccess... voila
 

Transition

Banned
Sep 8, 2001
2,615
0
0


<< put this on top:

RewriteEngine On

then it should redirect it.

here are some more information about htaccess... voila
>>



Negatory..

RewriteEngine On
RewriteOptions inherit

Gave me an internal server error...
 

kt

Diamond Member
Apr 1, 2000
6,032
1,348
136
Are you using Apache? If so, it's possible for you to use the rewrite engine to do this task. I am kinda rusty with .htaccess codes, but it's something along the line like this:

---start of code---
RewriteEngine on
RewriteBase /

RewriteRule ^(.*)\.htm$ $1 [C,E=WasHTML:yes]

RewriteCond %{REQUEST_FILENAME}.shtml -f
RewriteRule ^(.*)$ $1.shtml [S=1]

RewriteCond %{ENV:WasHTML} ^yes$
RewriteRule ^(.*)$ $1.htm
---end of code---

This is what the above code does, when a user request a page, ie index.htm it will look if index.shtml exist. If it does, then it rewrites the link to index.shtml. If not, then it will leave it alone and leave the link as index.htm and you'll get the 404 message. Hope that helps.


 

Lars

Diamond Member
Jan 10, 2001
3,379
0
0


<< I am kinda rusty with .htaccess codes, but it's something along the line like this >>



Obviously not as rusty as I am. :eek:
 

kt

Diamond Member
Apr 1, 2000
6,032
1,348
136
put it inside your .htaccess file

have it as far down as possible.
 

Transition

Banned
Sep 8, 2001
2,615
0
0
Actually i already had to change the .htaccess cause it wouldn't allow users to see any files.. 20,000 hits a week, i already had customers telling me the site wasn't working about 30 seconds after the change!

 

kt

Diamond Member
Apr 1, 2000
6,032
1,348
136
Hmm.. what else do you have in the .htaccess file? I tried out the code on one of our servers, it's redirecting just fine.
 

perry

Diamond Member
Apr 7, 2000
4,018
1
0
Setup a test directory so you aren't breaking your live site...



<< RewriteRule ^(.*)$ $1.shtml [S=1]
>>



Try changing that to

RewriteRule ^(.*)$ $1.shtml [S=1,R]

Actually, now that I test that out, I'm getting a 500 as well...

 

Transition

Banned
Sep 8, 2001
2,615
0
0
Hrm this is the error i get:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@hallusin8.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


Something is not configured right on my server perhaps? Suggestions?
 

kt

Diamond Member
Apr 1, 2000
6,032
1,348
136


<< Do you have mod_rewrite installed? >>


good question..
 

Transition

Banned
Sep 8, 2001
2,615
0
0
Hrm... What can i do to get this going then? If i call the hosting company what can i tell them so i can get the re-write process working?
 

kt

Diamond Member
Apr 1, 2000
6,032
1,348
136


<< Hrm... What can i do to get this going then? If i call the hosting company what can i tell them so i can get the re-write process working? >>


Tell them you need to have mod_rewrite module installed on the Apache server your website is hosted on.