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
247 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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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 …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now