Redirect rule to new site still requires old site to be active

Redirect rule to new site still requires old site to be active - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the Redirect rule to new site still requires old site to be active error on your web browser. Problem :


I have two websites being served on IIS 7.5 Windows Server 2008, with one site (projects.com) recently moved so that it now sits under the 2nd site (mainsite.org). This sub-site has numerous resources such as docs, PDFs, MP3s, PPts, etc..., which many sites have links to and people have bookmarks for.



I have been asked to write a rewrite/redirect rule so that when a resource link is pointed to the sub-site's old URLs the user is redirected to where it now sits on the new site (without receiving a 404).



The structure looks something like this:



Old URLs for projects.com:

projects.com/~abc/assets/pdfs

projects.com/~abc/assets/docs



New URLs for mainsite.org:

mainsite.org/abc/assets/pdfs

mainsite.org/abc/assets/docs



The inbound rule, which was written under projects.com, looks like this, and is for all practical purposes working:



[rule name="ABC resources redirect" stopProcessing="true"]
[match url="^~abc/assets/(w+)/(w+).(w+)" /]
[action type="Redirect" url="http://mainsite.org/abc/assets/R:1/R:2.R:3" appendQueryString="false" /]
[/rule]


*where R:1/R:2.R:3 = subfolder/filename.ext



Now my problem is that if the link to the resource is pointed to the old URL, the resource requested must continue to exist under the old projects.com site AND an identical copy be present under the new site as well. If not, a 404 error is displayed rather than a redirect occurring.



This means having to keep the same resource in two places, and this kind of redundancy is not good.



Additional issue: when I go directly to the PDF file at: projects.com/~abc/assets/pdfs/anchors.pdf, I am properly redirected to: mainsite.org/abc/assets/pdfs/anchors.pdf and the PDF file opens in the browser



However, when I go to other mime types: projects.com/~abc/assets/docs/questions.doc OR
projects.com/~abc/assets/ppt/grand_opening.ppt, the documents automatically download (or a prompt to 'save' is displayed, depending on which browser I use).



But after the download has occurred, the URL in the address bar does not reflect the redirect, it remains the old URL (a little confusing), though the documents are being downloaded from the mainsite.org site.



I feel like perhaps my approach is conceptually flawed. Any suggestions for resolving this redundancy issue?


Solution :

It sounds like your IIS rewrite rule is more complex than it probably needs to be. Try this one:



<rule name="ABC resources redirect" enabled="true" stopProcessing="true">
<match url="^~abc/assets/(.*)" ignoreCase="true" />
<action type="Redirect" url="http://mainsite.org/abc/assets/R:1" />
</rule>


That should 301 redirect URLs containing ~abc/assets/(followed by a file with any file extension and case) to the new site's URL.



You can test and modify this using the IIS "Test pattern" tool as covered here: Microsoft IIS.net - Testing Rewrite Rule Patterns



Also be sure to completely clear the cache in your browser between each test.



If you still have an issue with mime types, then I'd suggest posting another question specific to that.


We hope that this article has helped you resolve the redirects, url-rewriting, iis7 error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=