Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Whats the nest way to deal with changing htm to asp links

Status
Not open for further replies.

leeboycymru

Programmer
Jan 23, 2007
185
GB
I am re-doing a website to incorporate and databse and all, and basically it has been around for a while and doing very well in the search engines.

Currently they are all .htm file extensions, and so when i change it all over .asp extensions he will loose his links in the search engines.

I heared that it can be done using 404 error pages, is this right, and if so how can it be done. This will be the first time I have ever dealt with this, so it maybe a bit over my head, but I would love to understand how to do it.

lee
 
Hi

leeboycymru said:
Currently they are all .htm file extensions, and so when i change it all over .asp extensions he will loose his links in the search engines.
You did not mentioned what web server are you using. But is a quite basic feature to configure what to be parsed for code. So I would just configure the web server to handle .htm files as ASP.
leeboycymru said:
I heared that it can be done using 404 error pages, is this right, and if so how can it be done.
That is a last solution. Just configure the web server to do the redirection automatically. Anyway, the custom 404 error document should do the same : send back a 301 Moved Permanently response status code and the new URL, as described in HTTP 1.1 protocol.

By the way, if you did not already done, read thread828-1321205.

Feherke.
 
You need to issue 301 redirects when the htm page is called and send the request on to the new asp page.

This could be done by creating a custom 404 page that included some asp script to check what page was requested and issue the necessary redirect.

Try this as a starting point

But you will need to find out how to issue the 301 code as this is the key.



<honk>*:O)</honk>

Earl & Thompson Marketing - Marketing Agency Services in Gloucestershire
 
Hi

Sorry Foamcow, but I still think that involving the 404 error handling is unnecessary. Modern web servers can be configured to do that.

In Apache using the [tt]RedirectMatch[/tt] directive :
Code:
RedirectMatch 301 (.*)\.htm$ $1.asp
In lighttpd using the [tt]url.redirect[/tt] option :
Code:
url.redirect = ( "(.*)\.htm" => "$1.asp" )
If lee will tell us what web server he use, probably someone will give him the suitable configuration for that one.

Feherke.
 
Ok sorry guys, I have just checked and I hope im right in that im on a server Featuring IIS6, of a Microsoft web server software.

Does this help, and in honesty all that you have been talking about above is over my head really, so if you could explain it step by step that would be great.

Lee
 
Feherke, I tend to agree with you particularly if there are alot of pages.

But won't that method only work if the file names are identical except for the file extension?
Is it possible to configure IIS to redirect, for instance, mypage.htm to contact.asp ?

Also, doesn't it also become inefficient parsing all htm files as asp? Or does the asp parser only use server processes if there is actual asp content?

<honk>*:O)</honk>

Earl & Thompson Marketing - Marketing Agency Services in Gloucestershire
 
In relation to the comment above with regard to the file names being identical, I have done that where possible but in others i have trimmed the amount of pages down to one single page in some cases and dealt with different subjects by passing variables over to the page, so in some cases a page has gone from being .../mahoganyclocks.htm to .../display.asp?mahoganyclocks

What i need to be able to do is in some cases when a link in the search engine is clicked that has ../mahoganyclocks.htm for a script to recognise this link and redirected the user to a page as above with variables controlling the content.

Lee
 
Hi

Foamcow said:
But won't that method only work if the file names are identical except for the file extension?
When I suggested that code, that was what lee mentioned : changed the extension.
Foamcow said:
Is it possible to configure IIS to redirect, for instance, mypage.htm to contact.asp ?
When I suggested that code, the web server name was not specified yet. I do not know for what IIS can be configured and I not even want to find out.
Foamcow said:
Also, doesn't it also become inefficient parsing all htm files as asp?
lee wrote about changing all, so no more .htm would mean no inefficiency.
Foamcow said:
Or does the asp parser only use server processes if there is actual asp content?
Sorry, my point of view regarding ASP is exactly the same as mentioned above for IIS.

Feherke.
 
Feherke
lol
Yep, I avoid IIS/ASP if I can too :)
But remember, this is a 404 page, so it will only be called when someone follows an out of date link. It's not like it's running for every request made. It will not incur the overhead that forcing every html page to be parsed as asp/php nor will it incur the same overhead as using, say, an .htaccess file with lots of URL ReWrite directives.

Appreciated, Leeboycymru didn't specify the server platform in the inital post, but he's using asp so it's a reasonable assumption he'd be using IIS. I know you can run PHP on a windows server but I don't think it's the norm for public facing web servers.

Leeboycymru.
Bore da!

Feherke is correct in all that he says but for your case you would probably be best served using a 404 page with an asp script. Once the search engines have reindexed the pages with the new URLs then the 404 won't get hit anywhere near as much. You may even want to remove the script from the 404 page at some point in future.

Did you read the 4GuysFromRolla page I linked to? That will tell you how to do it.

One thing to be careful of though and I'm not exactly how you are working things but...
If you are passing a page name as a parameter in the querystring then you MUST ensure that it is only possible to call pages from your own site. If you are pulling pages from a database table then I assume the name 'mahoganyclocks' would be a key within the table rather than a filename. Is that correct? If so, then you are probably ok.
Just be aware that if you are calling files into a page using the querystring it may be theoretically possible for someone to pull a malicious script into your page.
This is probably a discussion for a different forum though. Just though I'd give you a heads up.

<honk>*:O)</honk>

Earl & Thompson Marketing - Marketing Agency Services in Gloucestershire
 
Bore da Foamcow, good result on Saturday for us boyos!

I didnt read the 4GuysFromRolla page, but I will do now.

I hope its not to much over my head, but I will give it a go.

And yes mahoganyclocks is a key in the table, the page is display.asp and that will display the stock depending on the paramater.

Diolch yn fawr!

Leeboy
 
simplest option is to change the application mappings to allow .htm to parse as asp


there is no extra security risk (the common excuse) and the additional load (IIS4 plus) is negliable




Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top