rewrite page from cname domain - iis-7

I have two sites:
http://blog.site.com and http://www.site.com
Both sites are on different servers and different IP addresses (different hosting providers).
I would like to create rule which helps to rewrite the page
The URL will look like
http://www.site.com/logs/current_pages/ to the site visitor but it will really hit
http://blog.site.com/logs/current_pages/
Is it possible?
Please check this, it is not working
<rule name="cname domain">
<match url="/logs/(.+)" />
<action type="Rewrite" url="http://blog.site.com{R:0}" appendQueryString="false" />
</rule>

Related

Can you change your primary Wordpress URL without breaking the old url?

When I installed Wordpress I decided on what I thought would be a decent URL and started writing blog posts and pointing people to www.moreGenericDomain.com/myblog/. Everything worked, and still works, fine. But as my blog focus was narrowed the domain didn't quite suit it anymore.
I've since purchased a new domain that I would like to use. When I go into settings and set www.NewDomain.com as the blog address everything works fine for that domain. Further, the urls are cleaner as they have changed from www.moreGenericDomain.com/myblog/post-1 to www.NewDomain.com/post-1. So everything seemed to go going great.
However, after this change www.moreGenericDomain.com/myblog/post-1 would give a Wordpress 404 page. This is very undesirable as I already have a number of links to my blog posts and a few initial subscribers. I don't want to lose this established traffic that I've worked so hard for.
Is it possible to switch to the new domain name while keeping the old one functional? In other words, I would like www.moreGenericDomain.com/myblog/post-1 to redirect to www.NewDomain.com/post-1.
Update
Per some helpful tips in the comments I tried setting up rewrite rules. My web.config looks like this:
<rewrite>
<rules>
<rule name="multAccounts">
<match url="http://oldDomain.com/LMBlog/post-1/" />
<action type="Rewrite" url="http://newDomain.com/post-1/" />
</rule>
<rule name="darkEssences">
<match url="http://oldDomain.com/LMBlog/post-2/" />
<action type="Rewrite" url="http://newDomain.com/post-2/" />
</rule>
<rule name="GuildBash">
<match url="http://oldDomain.com/LMBlog/post-3/" />
<action type="Rewrite" url="http://newDomain.com/post-3/" />
</rule>
<rule name="KvK">
<match url="http://oldDomain.com/LMBlog/post-4/" />
<action type="Rewrite" url="http://newDomain.com/post-4/" />
</rule>
</rules>
</rewrite>
The first rule seems to work correctly, while IIS ignores the other 3. I've used IIS' rule editor to test my input URL and it says it matches, but when I go to that URL I am not redirected and Wordpress gives me a 404.
I also tried a regex rule:
<rules>
<rule name="RegexRewrite">
<match url="([a-zA-Z\-\:\/]+)oldDomain.com\/lmblog\/([a-zA-Z\-]+)" />
<action type="Rewrite" url="http://NewDomain.com/{R:2}" />
</rule>
</rules>
However, that is completely ignored; no rewrites occur at all and I received the Wordpress 404 page. I suspect that Wordpress is preventing IIS from doing url rewrites.

IIS URL Rewrite Domain change 301 redirect individually only some pages and all other pages to another URL

I am new to IIS URL Rewrite rule Regex and looking for help here.
This is a sitecore web site which is built in ASP.NET MVC. I have a one domain i.e. www.xyz.com get merged with the another domain i.e. www.abc.com . I have the 1 to 1 mapping of both www.xyz.com/test -> www.abc.com/test1 . ALl the internal pages of www.xyz.com/xx will be mapped with the www.abc.com/foo except Homepage of www.xyz.com
I am currently stuck at how can i,
1) Redirect www.xyz.com/ homepage to a third party URL?
2) At the same time keep the 1-1 mapping of www.xyz.com/internal pages with www.abc.com/internal pages
I am using IIS URL Rewrite rule to do a domain redirect of www.xyz.com to www.abc.com and looking for additional help with the homepage redirect with a third party page
Thanks in Advance!
you just need two different redirect rules, the first rule will check for the root domain and redirect to third party url and the second rule will check for internal pages and redirect to internal pages on the new domain
it will look something like this
<rule name="redirect root to third party" stopProcessing="true">
<match url="^$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="(www.)?xyz\.com$" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="<third party url here>" />
</rule>
<rule name="redirect to new domain" stopProcessing="true">
<match url="/(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?xyz\.com$" />
</conditions>
<action type="Redirect" url="http://<new domain>/{R:1}" redirectType="Permanent" />
</rule>
P.S: in the second rule, please check for / -- i have not tested the rule myself there could be an extra slash introduced in the destination url or a slash removed, whatever it is you will be able to fix it. The main point here is you need two separate rules one for checking the exact domain with nothing after it and redirecting to third party and another rule for sub page redirects

301 redirect in IIS

So we have a client whereby we are hosting their site but with 2 different domains mapped (we have bindings for both domains) to the same site in IIS. this is primarily because when they started with us they could only purchase the domain they didn't ultimately want to use going forwards.
For example the domains are www.some-thing.com and www.something.com.
They have asked if I can put a 301 permanent redirect in on the URL with the hyphen so then users should always go to the non hyphen version of the site.
I have tried URL rewrite rules and using the HTTP redirect in IIS however the site is then in a re-direct loop and I think this is down to the fact I have both domains bound to the site in IIS.
Help !!
Thanks in advance
Try this URL Rewrite .Here is the Source
<rule name="fromadd Host Name" stopProcessing="false">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^anitkb\.com$" />
</conditions>
<action type="Redirect" url="To address" redirectType="Permanent" />
</rule>

IIS Rewrite Rule: Redirect old domain to specific page in new domain

We have a requirement where we need to redirect the old domain to specific page in new domain.
e.g.
GIVEN I navigate to http://old.domain.com
THEN I should be redirected to http://new.domain.com/apple
GIVEN I navigate to http://veryold.domain.com
THEN I should be redirected to http://new.domain.com/apple
I had a look at link below which suggest it's not possible with DNS redirect:
Using DNS to redirect to another URL with a path
I'm not really good on IIS Rewrite rules.
Can someone please help?
I've started with below which doesn't seem to be working well:
<rule name="Redirect old domain to new domain page" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^old.domain.com$" />
</conditions>
<action type="Redirect" url="http://new.domain.com/apple" redirectType="Permanent" />
</rule>

User specific rewrite rules

I am developing a website that each user can point his domain to this website. while some of the resources are shared each user can design his own unique website using plugins, ...
I want to create rewrite rules specific for each user. these rules are unique per user but not necessarily in global.
<rewrite>
<rules>
<rule name="Products" enabled="true" stopProcessing="true">
<match url="products/(.+)" />
<action type="Rewrite" url="products.aspx?id={R:1}" />
</rule>
</rules>
</rewrite>
each user will have many rewriting rules each based on content of their own website. I can't just add all rules to one web.config file, right?
what can be done here?

Resources