.NET Forum / ASP.NET / General / March 2008
301 redirect HTML to ASPX. options?
|
|
Thread rating:  |
Darrel - 28 Dec 2007 00:03 GMT I'm helping convert a 300+ page .html site into an ASP.net site.
The client wants to set up 301 redirects for all of the old html pages. I've used ISAPI for this type of thing in the past, as it works great and is easy to set up, but at this point, the client (which is my client, who's working with the actual client) doesn't know what the new web host supports.
In the interim, I want to do a bit of research myself on this to see if it's anything I can handle on my end. It's in asp.net 1.1 right now, and from what I can tell, it's quite easy to add a 301 redirect to an existing aspx page. However, these are all .html pages, so it appears I'm out of luck with that.
Do I have any other options to pursue outside of ISAPI Rewrite?
Converting to 2.0 probably isn't an option for this project, but that would help in the future, correct, as ALL files can be intercepted by the .net engine, correct? If that's true, is there any way to leave the current site as an ASP.net 1.1 site but run a 'wrapper' application of some sort in 2.0 that can handle the 301 intercept/rewrites?
-Darrel
Mohamad Elarabi [MCPD] - 28 Dec 2007 01:21 GMT You can do this in IIS. You can set IIS to redirect to a URL if a certain page is hit. This could be done for a single page, an entire folder, or an entire web site. To do that go to the properties window of either a page, a folder or a website and click on the "Home Page" tab, choose the radio option titled "A redirection to a URL" then in the test box below write the exact URL you'd like to be redirected to. You can also use $S in that url to pass the original url to your asp page, ans $Q will pass the original querystring. So your url could be
http://myNewApp/myPageHandler.aspx?OURL=$S&$Q
Hope this helps.
 Signature Mohamad Elarabi MCP, MCTS, MCPD.
> I'm helping convert a 300+ page .html site into an ASP.net site. > [quoted text clipped - 18 lines] > > -Darrel Darrel - 28 Dec 2007 02:34 GMT > You can do this in IIS. You can set IIS to redirect to a URL if a certain > page is hit. This could be done for a single page, an entire folder, or an [quoted text clipped - 12 lines] > > Hope this helps. I've done that myself, but, again, not sure what kind of access we're going to get to the server itself, if any.
Also, there's about 300 separate URLs that they need to set redirects up for. I really think ISAPI is the way to go, but just in case, thought i'd check on whatever other options we might have.
-Darrel
Mohamad Elarabi [MCPD] - 28 Dec 2007 04:53 GMT You could put the old url and the new url in a sql table or a file and have one page that looks it up in the table and redirects. You can then set one redirect in IIS on the web site level to send all traffic to your new page instead of 300 different ones, one for each page.
 Signature Mohamad Elarabi MCP, MCTS, MCPD.
> > You can do this in IIS. You can set IIS to redirect to a URL if a certain > > page is hit. This could be done for a single page, an entire folder, or an [quoted text clipped - 21 lines] > > -Darrel Darrel - 28 Dec 2007 06:05 GMT > You could put the old url and the new url in a sql table or a file and > have > one page that looks it up in the table and redirects > You can then set one > redirect in IIS on the web site level to send all traffic to your new page > instead of 300 different ones, one for each page. Ah! That might work! So, IIS redirects to my page, and my page then does the 301 redirect. In that case, what kind of redirect do I use in IIS?
-Darrel
Mohamad Elarabi [MCPD] - 28 Dec 2007 10:20 GMT IIS would be set to redirect to a single URL as I specified in my original post. You would right click on the web site/Properties/Home Page Tab/"A redirection to a URL" and in the text box you'd specify the exact url to your new redirector aspx page and pass it the old url in the query string. It should look something like this
http://myNewAppDomain/myRedirectorPage.aspx?OldURL=$S
Note that the $S should translate to the originally requested URL and it should come to youe aspx page in a querystring variable called OldURL. You'd parse that value and use it to lookup the page that you'll need to redirect to.
If your aspx page is on the same site you can specify a virtual path instead of an http:\\... one. There are other redirection options like redirecting to a virtual folder under the same website. Unfortunately I am unable to help you with anymore specific details since I don't have access to an IIS6.0 box at the mean time. All I have access to is IIS7 on my vista laptop which is entirely different. So hopefully the IIS interface is intuitive enough for you to maneuver, I'm sure you can figure it out at least by trial and error if need be. Also consider doing a Server.Transfer in your redirector page to save a roundtrip this way your clients won't take 3 requests to get to their target.
Hope this is clearer. Let me know.
 Signature Mohamad Elarabi MCP, MCTS, MCPD.
> > You could put the old url and the new url in a sql table or a file and > > have [quoted text clipped - 7 lines] > > -Darrel Mark Stevens - 28 Dec 2007 08:04 GMT >You could put the old url and the new url in a sql table or a file and have >one page that looks it up in the table and redirects. You can then set one >redirect in IIS on the web site level to send all traffic to your new page >instead of 300 different ones, one for each page. Or make the root name of the aspx page the same as the html. You can then replace the html in the original URL string with aspx and redirect. That way you do not need the sql table the rest of the redirect would remain as described.
This method also has the side effect that the structure of the site remains the same so anyone working on the system using the old html files will be familiar with the new layout. Effectively they are the same.
Cheers, Mark
 Signature |\ _,,,---,,_ A picture used to be worth a ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along |,4- ) )-,_. ,\ ( `'-' came television! '---''(_/--' `-'\_)
Mark Stevens (mark at thepcsite fullstop co fullstop uk)
This message is provided "as is".
Mohamad Elarabi [MCPD] - 28 Dec 2007 10:08 GMT That would be true if he had 300 different aspx pages. But I doubt he has as many aspx pages as his old HTML ones otherwise why bother with aspx. My assumption is that he has a handful of aspx pages that can serve up dynamic content that used to be hosted over 300 different html pages.
 Signature Mohamad Elarabi MCP, MCTS, MCPD.
> >You could put the old url and the new url in a sql table or a file and have > >one page that looks it up in the table and redirects. You can then set one [quoted text clipped - 13 lines] > Cheers, > Mark Darrel - 30 Dec 2007 21:28 GMT > That would be true if he had 300 different aspx pages. But I doubt he has > as > many aspx pages as his old HTML ones otherwise why bother with aspx. Exactly. ;o)
Your answer makes sense. Though, is this HAS to be a 301 redirect. Does the method of using the one aspx page result in (or can it result in) a 301 redirect message being sent back?
Mohamad Elarabi [MCPD] - 30 Dec 2007 23:09 GMT IF you do a response.redirect(RedirectionURLHere) then it is a 301 redirect but if you do a Server.Transfer it won't look like a redirect to the client. In general you want to minimize the number of 301 redirects because each one is a round trip between the server and the client. So you set IIS to do a redirect to your ASPX page and then your page can redirect again to the target alternative. Now I'm not sure if the IIS redirect is a 301 or is it seamless to the client, but my guess is that it is a 301 redirect. However, if IIS doesn't do a 301 and you insist on having a 301 then your ASPX can do a Response.Redirect instead of a Server.Transfer.
In any case your client will not see a page that says "This page has moved, you will be redirected in 5 seconds, if you're not redirected click here . . . " because this kind of page is something you'll need to write yourself. So if that is what you want then your aspx page will need to do so and set a refresh on the body tag of the page.
Hope that helps.
 Signature Mohamad Elarabi MCP, MCTS, MCPD.
> > That would be true if he had 300 different aspx pages. But I doubt he has > > as [quoted text clipped - 5 lines] > method of using the one aspx page result in (or can it result in) a 301 > redirect message being sent back? chanda roopesh - 07 Mar 2008 16:06 GMT can u tell how to convert HTML pages to ASPX plzzz
George Ter-Saakov - 07 Mar 2008 16:33 GMT Just rename them from .htm to .aspx Also you will need to add first line <%@Page%> (may be not i am not sure).
George.
> can u tell how to convert HTML pages to ASPX plzzz > > *** Sent via Developersdex http://www.developersdex.com ***
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|