Navigate
Home
ArticleWiki
Forum
Journal
Search
Newsletter
Links
Tech News
expertsrt.com
Welcome Guest.
Username:

Password:

Remember me

Redirecting to a new URL
Welcome, Guest. Please login or register.
December 02, 2008, 01:19:49 PM
11304 Posts in 1248 Topics by 498 Members
Latest Member: katCheeme
Experts Round Table Network  |  Webservers  |  IIS  |  Redirecting to a new URL « previous next »
Pages: [1]
Author Topic: Redirecting to a new URL  (Read 1196 times)
chilipepperjeep

Offline Offline

Posts: 7



« on: March 04, 2006, 10:40:19 AM »

I’ve got to split my web site and move one of the folders to a new url.  I would like to redirect all of the links others have made to the old site's url to the new url.  There are literally hundreds of links posted all over the web in the form of:

  http://oldURL.com/oldFolder/showlist.asp?type=2&owner=67

That need to be redirected to:

 http://newURL.com/newFolder/showlist.asp?type=2&owner=67

What would be the best way to do this? (can it even be done?)
Logged
COBOLdinosaur
ERT.com Admin

Offline Offline

Posts: 481



WWW
« Reply #1 on: March 04, 2006, 11:00:42 AM »

Well there is nothing you can do in HTML to solve, unless you want to duplicate the page and put code in every one of them.  

You need to do a re-direct server side.  

SO let me know what you are running on the server side and I will move the topic to the right forum. IIS?  Apache?
Logged
chilipepperjeep

Offline Offline

Posts: 7



« Reply #2 on: March 04, 2006, 12:04:44 PM »

Quote from: "COBOLdinosaur"
Well there is nothing you can do in HTML to solve, unless you want to duplicate the page and put code in every one of them.
 Ouch! no I don't want to do that.  I was thinking about a custom 404 page written using php.

But this
Quote
You need to do a re-direct server side.  

SO let me know what you are running on the server side and I will move the topic to the right forum. IIS?  Apache?
sounds like a better idea.  My site is running on IIS.
Logged
COBOLdinosaur
ERT.com Admin

Offline Offline

Posts: 481



WWW
« Reply #3 on: March 04, 2006, 01:23:39 PM »

Okay it is moved to IIS.  Too bad it was not apache, Then we could probaly have done it with entries in the .htaccess.  I'm not sure what IIS has as equivelant but there must be something.  It is not like it is a rare occurance to have to move pages.


The problem a custome 404 page is that I doubt it could handle the argument string, so you could do a site re-direct, but not a page re-direct.

All we should need to do is send a re-direct header back to the browser, but i don't know how you tell IIS to do that.

Based on the server stats the M$ folks on the site are minority, so we will have to wait until one of them get IE to work long enough to post a solution.  :wink:
Logged
VGR
Mentor

Offline Offline

Posts: 682



WWW
« Reply #4 on: March 04, 2006, 04:54:36 PM »

Quote from: "COBOLdinosaur"
Okay it is moved to IIS.  Too bad it was not apache, Then we could probaly have done it with entries in the .htaccess.

Or with a rewrite rule

i'm sure you can find ongoogle the solution to your problem. I would start with "+redirect +IIS" or "what equivalent rewriterule +IIS"

Quote from: "COBOLdinosaur"

The problem a custome 404 page is that I doubt it could handle the argument string, so you could do a site re-direct, but not a page re-direct.

yes we can, I did it for my ErrorDocuments. You can also use SSI (if I remember well)
Quote from: "COBOLdinosaur"

All we should need to do is send a re-direct header back to the browser, but i don't know how you tell IIS to do that.

Well, i think you in fact touched the other possible solution : on all scripts accessed into http://oldurl/something, add on top the famous :
Code:
<?php
header("Location: newurl{$PATH_INFO}{$QUERY_STRING}");
exit;


(or the like, I didn't check for all possibilities. You could also check the $_POST and $_GET arrays to know what to redirect exactly )

A RewriteRule is definitely simplier, but you've to either (1) find a way to do it in IIS, (b) upgrade to Apache ;)
Logged

techie overlord, answers all kind of questions on http://www.europeanexperts.org
chilipepperjeep

Offline Offline

Posts: 7



« Reply #5 on: March 18, 2006, 09:13:37 PM »

Thank you all for your responses.  In the end this is how I solved the problem

<%
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.newurl.com" _
&Mid(Request.ServerVariables("SCRIPT_NAME") , 11, 200) _
& "?" & Request.ServerVariables("QUERY_STRING")
Response.End
%>

The new site has a different (simpler) directory structure than the old one so I strip some extra characters from the first part of the url.  It seems to work ok so far, no complaints.

Thanks again
Logged
Pages: [1]
« previous next »
    Jump to: