Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

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

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
Caiapfas
Asked:
Caiapfas
  • 7
  • 7
  • 3
2 Solutions
 
GoSuCommented:
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
 
plqCommented:
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
 
GoSuCommented:
As in the Standard 404 page?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
plqCommented:
Sorry yes, thats what I meant.
0
 
CaiapfasAuthor Commented:
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
 
GoSuCommented:
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
 
GoSuCommented:
>>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
 
plqCommented:
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
 
CaiapfasAuthor Commented:
so where do i put the javascript, on EVERY page?
0
 
plqCommented:
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
 
GoSuCommented:
RE 404
OTTOMH I don't know for apache (I'm mostly an IIS guy too)
0
 
plqCommented:
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
 
CaiapfasAuthor Commented:
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
 
plqCommented:
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
 
GoSuCommented:
>>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
 
GoSuCommented:
I'm too slow.. plq's solution is better anyhow becuase mine won't catch "blah.HTM"
0
 
plqCommented:
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 7
  • 7
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now