I'm trying to add several subdomain forwards to external URL's, I have moved for domain from GoDaddy to Cloudflare for the purpose of security, speed and safety. Although GoDaddy makes it very easy to set up subdomain fowards, Cloudflare doesn't seem to do so. Is there a way to do subdomain forwards on Cloudflare without using Page Rules, I've searched and can't find a way to do this. Thanks!
e.g. blog.magnaboy.com ----> magnaboysblog.com etc
You would do this by setting as DNS entry for 'blog' as a CNAME to *. Then in the root of the site use .htacess (linux) or web.config (windows) to consolidate the naked domain name.
Here is the web.config example:
<!--# CONSOLIDATE DOMAIN NAME -->
<rule name="Point to naked domain" stopProcessing="true">
<match url="(.*$)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" negate="true" ignoreCase="true" pattern="^magnaboy\.com$" />
</conditions>
<action type="Redirect" url="http://magnaboy.com/{R:0}" redirectType="Permanent" />
</rule>
This will 301 redirect anysubdomain.magnaboy.com to magnaboysblog.com
Related
We have a requirement for redirecting couple of webpages to different URLs of our website. For instance:
https://old-domain/-->https://new-domain/;
https://old-domain/promotion/campaign-->https://new-domain/;
https://old-domain/about-us-->https://new-domain/about-us/company;
https://old-domain/about-us/awards-and-recognitions-->https://new-domain/about-us/company;
https://old-domain/careers-->https://new-domain/careers/;
https://old-domain/careers/apply-for-a-job-->https://new-domain/careers/;
https://old-domain/claim-status-->https://new-domain/;
https://old-domain/contact-us-->https://new-domain/contact-us;
We need generic rewrite rules for the above, where
we either redirect to the desired destination URLs (manually hard-coding them in the rewrite rules)
or
add a single redirect rule for the first URL and regex expression to skip the rest (since the rest can be managed internally within the CMS but not the first)
I would do it via IIS Rewrite Rules in the web.config (unless the client requires to be able to edit those in the UI)
I would add a rule for each Url (or maybe combine a few where possible)
They could look like this:
<rewrite>
<rules>
<rule name="Redirect old domain" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="[www.]oldDomain.com$" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://www.newDomain.com/{R:0}" />
</rule>
....
</rules>
</rewrite>
Edit: Updated the rule above so that it will cater for any page on the old domain and will redirect to the same page of the new domain.
Examples:
www.olddomain.com will redirect to www.newdomain.com
www.olddomain.com/about-us will redirect to www.newdomain.com/about-us
Now, you can create the /about-us page in Sitefinity and make it a redirect page and redirect to wherever you want.
The site I'm looking after has multiple canoncial domains - e.g.
example.com
example.com.au
example.co.nz
as well as some 'other' domains that need to be redirected to one of the canoncial domains (e.g. example.us should go to example.com).
All sites should be accessed via HTTPS
Is it possible to write a concise rule for each canoncial domain that redirects the user to that domain iff
They're not on the canoncial domain (e.g. www.example.com, example.us) OR
The connection is not HTTPS
I think I can see how to do it wih multiple rules, but it will quickly become fiddly (so concise rules would be nicer)
I achieved it with the following (shoved multiple variables into the input with a # delimter):
<rule name="Redirect to example.co.nz" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}#{HTTP_HOST}" pattern="(^OFF)|(^.*#www\.)" />
<add input="{HTTP_HOST}" pattern="^(www\.)?example.co.nz$" />
</conditions>
<action type="Redirect" url="https://example.co.nz/{R:1}" />
</rule>
Azure App Service AlwaysOn works perfectly once there is no custom domain set for the web application. Once custom domain is added along with URL rewrite rule to redirect all incoming request to it, application starts to response slowly after some time of inactivity. Logs show that AlwaysOn still pings azure domain and gets HTTP 301 response ans is not trying to request new URL.
Log without custom domain:
2017-06-20 17:17:02 ZZTESTSITE GET / X-ARR-LOG-ID=743965b6-d3e2-42b9-9353-7772f9fbc898 80 - ::1 AlwaysOn ARRAffinity=b5289afa9cd711b67c1fe9137a6e3ff232f80bd3fa1bd96e9fc89992472b4e57 - zztestsite.azurewebsites.net 200 0 0 11433 652 15
Log with custom domain
2017-06-21 13:28:52 ZZTESTSITE GET / X-ARR-LOG-ID=ffcd5992-5019-48ca-a386-76443a8c7226 80 - ::1 AlwaysOn ARRAffinity=b5289afa9cd711b67c1fe9137a6e3ff232f80bd3fa1bd96e9fc89992472b4e57 - zztestsite.azurewebsites.net 301 0 0 553 652 46
URL Rewrite rule:
<rule name="Redirect requests from default azure websites domain to custom one" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^zztestsite\.azurewebsites\.net$" />
</conditions>
<action type="Redirect" url="http://mycustomdomain.com" redirectType="Permanent" appendQueryString="false"/>
</rule>
Additionally once SSL in enabled and another rule is added to redirect all requests to HTTPS, same issue will arise.
How can I tackle this problem? I found two possible directions:
Push AlwaysOn to ping custom domain (possibly https as an option)
Change URL Rewrite rule to one allowing AlwaysOn to ping azure domain, but all other shall be redirected
Please advise.
Try adding this line to your conditions:
<conditions>
<add input="{HTTP_HOST}" pattern="^zztestsite\.azurewebsites\.net$" />
<add input="{WARMUP_REQUEST}" pattern="1" negate="true" />
</conditions>
This tells is not to redirect for the Always On pings. Also note that I removed the MatchAny, as you really want MatchAll here (irrelevant when you only had one).
See here for a more complete example. It's for redirecting http to https, but the core idea is the same with respect to Always On requests. That example is an xdt transform, so it looks a bit different from 'straight' config. In fact you might consider using such xdt instead of polluting your web.config.
Finally I found the rule which works
<rule name="AlwaysOn agent requests without any redirections" stopProcessing="true">
<match url="^$"/>
<conditions>
<add input="{HTTP_USER_AGENT}" pattern="^AlwaysOn$" />
</conditions>
<action type="None" />
</rule>
I put it as a first rule. Then other rules follow like "azure domain to custom domain redirect" and "HTTP to HTTPS".
David's answer was helpful however solves a bit different issue.
So I have a project in azure that is www.example.com and it has it's MVC file structure with source code and all. However, within that, I have another part that needs it own URL, www.example2.com which would point to a folder within this hierarchy. So you could reach this entry point from www.example.com/#/example2.html or simply from going to www.example.com. Hope that makes sense. So within Azure, how can I achieve this? I am looking through custom domain, but not seeing a way to go about this. Any ideas please?
Yes, using rewrite rules in your web.config. Adjust variables accordingly.
<rewrite>
<rules>
<rule name="Redirect domain" enabled="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www\.)?example2\.com$" />
</conditions>
<action type="Rewrite" url="folder/{R:1}" />
</rule>
</rules>
</rewrite>
Don't forget to add and authorize both domains to your web app.
I want to ensure that anybody who goes to http://example.com/* gets automatically redirected to http://www.example.com/*. Currently, IIS allows either URL form to work, meaning that any page can be accessed at multiple URLs, which has a number of disadvantages (SEO, etc).
Is there any way to do this built into IIS (especially IIS 6) without setting up a third-party rewriting engine like this? It seems like a bazooka to kill a mosquito.
The easy way would be to simply remove the DNS entries for 'www.mysite.com', so the only DNS entries that exist are for 'mysite.com'.
Alternatively, here's a couple of techiques for redirecting to a canonical URI:
http://www.kalyani.com/2010/01/redirecting-to-canonical-url-in-iis7/
https://web.archive.org/web/20211020203216/https://www.4guysfromrolla.com/articles/072810-1.aspx
http://www.stevenhargrove.com/redirect-web-pages/
Basically you want to hand back a 301 Moved Permanently status for the non-canonical URIs, along with the canonical URI so the user agent may load it instead.
I have another solution for you:
<rule name="Canonical domain name" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www\.([.a-zA-Z0-9]+)$" />
</conditions>
<action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>