Solved

file finder : I need a script that will redirect users to the samefile.asp from samefile.htm, so i cant rename all my files to .asp

Posted on 2004-04-05
18
251 Views
Last Modified: 2010-04-17
i need a script (perl) that will see users when they come to my site and if the user is trying for bigcars.htm, but i renamed it to bigcars.asp, it will redirect them to the right page, or what it thinks it the right page, bigcars.asp, and if possbile if i rename BiGcars.asp to bigCARS.asp it will match them together and redirect them...is this possible?
The only problem I see, is how will it montior users, access to my site and do this match up?
0
Comment
Question by:Caiapfas
  • 7
  • 7
  • 3
18 Comments
 
LVL 3

Expert Comment

by:GoSu
ID: 10761550
What is your Server Software and Installation of PERL? (ASP and PERL in the same sentence threw me off)

Anyhow mod_rewrite is what your'e looking for if you are on APACHE. If you're on IIS do a search for IIS mod_rewrite and plenty of alternatives/3rd party software comes up.
0
 
LVL 8

Expert Comment

by:plq
ID: 10761695
Can you just put a javascript on the page

<script language="javascript">
window.location.href=window.location.href.replace(".htm", ".asp");
</script>

just a thought!
0
 
LVL 3

Expert Comment

by:GoSu
ID: 10761709
As in the Standard 404 page?
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 8

Expert Comment

by:plq
ID: 10761748
Sorry yes, thats what I meant.
0
 
LVL 2

Author Comment

by:Caiapfas
ID: 10761886
plq, u mean put that on my 404 page and it will look for asp/htm files for that same file name?

GoSu, apache, what do i need to do..
0
 
LVL 3

Expert Comment

by:GoSu
ID: 10761893
A simple and elegant solution as long as Caiapfas doesn't mind the JavaScript requirment. Keep in mind it's completely cross browser too.
0
 
LVL 3

Expert Comment

by:GoSu
ID: 10761909
>>GoSu, apache, what do i need to do..
http://httpd.apache.org/docs-2.0/mod/mod_rewrite.html
Is the recommended 100% sure solution.

Though plq's solution is a LOT eaiser and will cover >90% of all users.
0
 
LVL 8

Expert Comment

by:plq
ID: 10761927
I haven't touched 404's for years.  GoSu can you remember how to do it. I think you have to look at the HTTP_REFERRER method in the script and then response.redirect or javascript it into that

I'm just researching some more now...
0
 
LVL 2

Author Comment

by:Caiapfas
ID: 10761978
so where do i put the javascript, on EVERY page?
0
 
LVL 8

Expert Comment

by:plq
ID: 10762003
OK forget about http_referrer etc, its browser dependent and unreliable.

window.location.href does contain the right value when I tested on IE with IIS

so all you need is the javascript I gave you, and repoint your 404 message to a page with that script in it. You don't need anything else in the file
0
 
LVL 3

Assisted Solution

by:GoSu
GoSu earned 250 total points
ID: 10762011
RE 404
OTTOMH I don't know for apache (I'm mostly an IIS guy too)
0
 
LVL 8

Expert Comment

by:plq
ID: 10762013
No your htm's don't exist any more right ? Because you renamed them to .asp

So using IIS or whatever, repoint your 404 page to 404.htm within your site directory

In 404.htm, make sure its empty and paste that javascript I gave you

That should be it. I just tested it and it works OK.
0
 
LVL 2

Author Comment

by:Caiapfas
ID: 10762025
so it will redirect to missing.htm to missing.asp?
and what about case senstive stuff?
can i do this?


also, how much does microsoft IIS run?
0
 
LVL 8

Accepted Solution

by:
plq earned 250 total points
ID: 10762034
You've got a point about case sensitive. Here;s the fix, a long as your querystrings aren't case sensitive (v.unusual)

<script language="javascript">
window.location.href=window.location.href.toLowerCase().replace(".htm", ".asp");
</script>

It will redirect missing,htm to missing.asp

I didn't understand the last question : also, how much does microsoft IIS run?
0
 
LVL 3

Expert Comment

by:GoSu
ID: 10762043
>>so it will redirect to missing.htm to missing.asp?
yes
>>and what about case senstive stuff?
That may pose a problem, if you have an all lowercase or all uppercase naming convention do this
window.location.href=window.location.href.replace(".htm", ".asp").toLowerCase();
or
window.location.href=window.location.href.replace(".htm", ".asp").toUpperCase();

Otherwise it all just depends.

>>also, how much does microsoft IIS run?
The Cost of a Windows server license. (In other words it comes free with Windows)
0
 
LVL 3

Expert Comment

by:GoSu
ID: 10762051
I'm too slow.. plq's solution is better anyhow becuase mine won't catch "blah.HTM"
0
 
LVL 8

Expert Comment

by:plq
ID: 10762076
I found this on setting 404 with apache

http://www.devarticles.com/c/a/Apache/Implementing-Sensible-404-Pages-With-Apache/1/

but you might get problems if IE users have friendly error messages turned on...

http://forums.devshed.com/archive/t-90288

This ones probably the best from the first page in google

http://www.thesitewizard.com/archive/custom404.shtml

My only experience with apache is how to turn it off, there I am an expert and thanks to jkr I can do it in VB, C++ or from Control Panel ! sorry must stop using the internet at 1am.



0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
This article will show, step by step, how to integrate R code into a R Sweave document
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question