301 Permanent Redirect to another Domain - iis

I want to Redirect the old domain to new domain and without having different resources for each is it possible to use the same resource in IIS for both domains? Any suggestions please let me know

IF I understand you correctly you want www.old.com to go to www.new.com. You should be able to put this in your web.config file of the old site.
<system.webServer>
<httpRedirect enabled=”true” destination=”http://www.my-new-site.com” httpResponseStatus=”Permanent” />
</system.webServer>
You can manually do it in IIS. Here are some steps.
Open IIS Manager and locate the website under sites
Important! Verify that it shows the correct website name at the top of the
screen
Under the IIS section open “HTTP Redirect”
Put a check in “Redirect requests to this destination” and type in the new URL
Change the status code to “Permanent 301″
Click Apply (this results in an HTTP status code of: HTTP/1.1 301 Moved Permanently)

Related

Redirect anything not already redirected with 301 on IIS7

We recently setup a new website on a new domain using WordPress, to replace our old website using flat files. Because of time constraints, we had little time to plan and ended up having someone setup the redirects in IIS Manager.
This means that almost every folder in the old website has something like the following for each page:
<location path="old-file.html">
<system.webServer>
<httpRedirect enabled="true" destination="http://new-domain.com/new-page/" exactDestination="true" childOnly="true" httpResponseStatus="Permanent" />
</system.webServer>
</location>
The problem is that this was a massive site with ~15k pages and only about 1k pages were manually redirected to new URIs. This means we have potentially 14k pages of legacy content (effectively dead URLs, some of it is so old) but we need to it redirect to the root of the new domain.
So almost every folder has a web.config with one instance of the codeblock above for each page redirected, but we need every page that wasn't redirected in this manner to redirect to a fixed location.
Manually configuring isn't an option because of the number of pages. I thought about using a tool to add a line of PHP to handle the redirect to every .php and .html file (PHP had to parse html files on this site for legacy content) but it's far from ideal.
Ideally, there'd be something I could put in the web.config which would say "For any request not already redirected via <location>, redirect it to "http:// domain.com". Even if this meant appending something to the web.config already in each folder, it would save days of work, say if no locations match, then redirect.
I've searched for having multiple locations or wildcards in <location> blocks but doesn't seem possible so I'm not sure what do do here—any help appreciated!
Suggestion: why not you redirect your 404 page to home page of any other you wish to.. if someone lands to any old page that no longer exists should go to 404 so redirect 404 to homepage, common practice in case of ecommerce sites they redirect their discontinued product page to search page. If that helps you can google "redirect 404 to homepage wordpress" there are lots of plugins that would do it, but as IIS you can simply config your web.config.
If the urls are now dead and you dont have replacement content to redirect them to, then the proper response would be to return a 404/410. Redirecting dead urls in bulk to the homepage will be seen by Google as a soft 404. https://support.google.com/webmasters/answer/181708?hl=en

IIS HTTP Redirection despite Sitecore installation

I am trying to have my Sitecore installation (IIS7.5 + Sitecore 6.5) take a subdirectory and redirect to an external website. For example:
www.domain.com -> Sitecore installed website
www.domain.com/anotherSite -> Redirects to www.anothersite.com/index.php?q=somestuff
I'm not very familiar with IIS (more of an nginx/apache guy), but I tried setting up a virtual folder for "anotherSite" then setting up an HTTP Redirect from that virtual folder to the destination. The probelm with that is that apparently Sitecore jumps in and tries to handle it before the redirect gets a chance and throws a 404.
Is there a way to intercept that one path in IIS before Sitecore gets involved and point it to an external URL?
Have a look at your web.config (or maybe a separate include file beneath ~/App_Data/Inlcudes) and search for a setting with the key IgnoreUrlPrefixes.
You might add the name of your virtual directory there to prevent Sitecore from processing these requests:
<setting name="IgnoreUrlPrefixes" value="...|/anotherSite" />

IIS 7.5 Custom 404 Error Page Not Working for Web Root Index/Default

Using IIS 7.5 I have created a custom 404 (and 403.14) error page that displays content from a database if a static file is not found.
In other words, if I browse to http://mysite.com/test/ and a physical index or default file is not found at that location then IIS executes my 404 custom error page which parses the url and either displays a page stored in a database, or a notice saying the page cannot be found.
Everything is working perfectly except that IIS will not display the 404 page for the web root index/default page.
There are no files in the web root directory - here are my observed results:
mysite.com: Completely blank page
mysite.com/: Completely blank page
mysite.com/index.aspx: Correctly displays my custom error page.
mysite.com/default.aspx: Correctly displays my custom error page.
mysite.com/index.htm: Correctly displays my custom error page.
mysite.com/anything_else/: Correctly displays my custom error page.
My Web.config file contains:
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/_page/" responseMode="ExecuteURL" />
<error statusCode="403" subStatusCode="14" path="/_page/" responseMode="ExecuteURL" />
</httpErrors>
I would like to store the contents of the home page in a database like the rest of the site's dynamic pages but after much searching still cannot find out how to get IIS to display my custom error page when the home index/default page is not found.
Any help/thoughts would be greatly appreciated.
fodder
I ended up solving this by using the web root index itself as the custom error page instead of another page like "/_page/".
This worked for everything except for SSL redirecting, which I decided was not a big enough issue to hold up the project.
In the system, every page is explicitly set to either http or https. If a user navigates to an https page using an http address then they are redirected to the https version and vice-versa. However, using the root index as the custom error page means that this redirection won't work for the home page because IIS will not redirect a page to itself for some reason.
If anyone has any idea how to get around that problem I'd greatly appreciate your thoughts. But the original question is essentially solved.
Hope reading this helps someone.
fodder
UPDATE - 08/17/2012:
Well, it took a support call to Microsoft (arduous, but eventually fruitful) but I finally found the answer to the underlying problem
When I first set up the web server, I did not install the "Directory Browsing" module for security reasons. I didn't want web clients to be able to see the file structure.
Well, it turns out that one needs to install the Directory Browsing module (EVEN IF IT IS DISABLED) to make IIS respond with anything besides a 200OK (and generate a blank html page).
Once installed (and left disabled, for security reasons), IIS now responds with a 403.14 Forbidden error, which I already had correctly redirecting in my web.config.

How to set up 301 redirects in Kentico CMS

How would you approach setting up 301 redirects within Kentico CMS (v5.0)?
I want to provide a client with an easy way (ideally through the CMS Desk interface) to set up 301 redirects in a website that has recently be re-implemented on Kentico. For example, I would want to redirect "old-page.cfm" to "new-page.aspx", and ensure that the HTTP response to the original request is 301.
I have an approach that looks like it works, but maybe there is a better way. I configured extensions-less URLs (per Kentico's documentation) and added a new document alias to the "new-page" document, specifying the "old-page" as the URL path and adding ".cfm" to the URL extensions list. Using Fiddler (HTTP Debugging Proxy) tool, it looks like what I want to have happen is happening: the request for "old-page.cfm" is returning a 301, redirecting to the "new-page" document, and returning a 200 response.
Does anyone know if this is a good approach for setting up 301 redirects in Kentico? Is there a better way? Are there any known drawbacks to using extension-less URLs in Kentico?
I think this is a good approach and I'm not aware of any other way to accomplish 301 redirects without doing what your doing. I've used Extension-less URLs in Kentico for awhile now and they work well.
According to a Blog Post (Comment) by the CTO of Kentico:
... there are few new (so far experimental) settings in 4.0 (4.0 ONLY) you can put in the web.config file.
They are:
3) <add key="CMSUsePermanentRedirect" value="true" /> which allows 301 redirection in places where it makes sense, instead of 302 redirection.
2) <add key="CMSRedirectAliasesToMainURL" value="true" /> which you can use for better SEO. It does 301 on every URL which is not main for the document (NodeAliasPath). That should help you for now.
3) <add key="CMSRedirectInvalidCasePages" value="true" /> which goes even further and allows you to restrict the pages only to a specific case variant. When the case is not right, it gets 301 to the right case.
I'm not sure what the status of these are with 5.X, but I'm guessing they either work, or they are now configuration settings somewhere in the Site Manager.
I would install the IIS Rewriter module http://www.iis.net/downloads/microsoft/url-rewrite
Then I would add a rule (permanent = 301) for all the .cfm pages to be processed by a custom handler.
For the customer I have to create a custom table with two columns that holds the relation between the old links and the new links.
That custom handler will then look into the custom table for any matches and then do the correct redirection.
I have implemented it in IIS6 for several clients moving from a php system to kentico using ISAPI Rewrite from Helicon (http://www.helicontech.com/isapi_rewrite/). It uses a .htaccess file at the root of the site. You could make this an edittable page from kentico if you needed to, or updatable from a custom field in page if you needed to, however we just got mapping list from our clients.
I believe you can do the same thing natively in IIS7 with one of the optional plugins.

Redirecting a domain using IIS

I am currently having two domains www.xyz.com and www.pqr.com. If anybody enters xyz.com I need to bringout the website pqr.com
Both are on the same server.
Kindly suggest how to go about this.
Thanks
In internet services manager, right
click on the file or folder you wish
to redirect then select "Properties"
Select the radio titled "a redirection to a URL".
Enter the redirection page
Check "The exact url entered above" and the "A permanent redirection for this resource"
Click on 'Apply'
From http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/6b855a7a-0884-4508-ba95-079f38c77017.mspx?mfr=true
To redirect requests to another Web
site or directory
In IIS Manager, expand the local computer, right-click the Web site or
directory you want to redirect, and
click Properties.
Click the Home Directory, Virtual Directory, or Directory tab.
Under The content for this source should come from, click A redirection
to a URL.
In the Redirect to box, type the URL of the destination directory or
Web site.
If you want to say that "you should always go to foo instead of bar," you want a 301 redirect (which you do with your front-end server). See http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=93633
A 302 (temporary) redirect should be used in cases where you can't serve a page, but expect it to come back later. Unfortunately, it's the redirect that you get from JSP forward.
A client-side (meta refresh or javascript) redirect should be avoided whenever possible.
Apache docs for configuring a permanent (or temporary) redirect.
If you want pqr.com to appear in the user's browser's address bar, you'll have to send a 301/302 redirect response, either through a script or through your web server's configuration - how to do this depends on what software you are using.
If you are using IIS7 and you have installed URL Rewrite Module then use this article for more information : IIS URL Rewrite – Redirect multiple domain names to one

Resources