Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
Medium Priority
?
260 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 750 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 750 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 …
Six Sigma Control Plans

636 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