Is it possible to redirect one domain (MyMenu.com) to two different destinations?
MyMenu.com ---> AzureStorageAccount (StorageAccount URL for static website)
Admin.MyMenu.com ---> AzureWebApp (https://ExampleMenuApp.azurewebsites.net/)
Note: I have a domain from GoDaddy (MyMenu.com). How to make Admin.MyMenu.com ?
Thanks in advance.
Yes, you can use rewrite. Code like below in web.config.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="mydomain.com" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^(admin.mydevapp.nl)$" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Redirect" url="https://examplemenuapp.azurewebsites.net/" redirectType="Temporary" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Test Result:
My domain config on portal.
Yes you can do that. Say you have mymenu.com, which is the root domain, and you have admin.mymenu.com which is a subdomain of mymenu.com. The subdomain is considered as an extension or a child item of the root domain and it can have its own properties, such has pointing to different IPs/websites etc.
Because you're using Azure Storage Account and Azure Web Apps, all you need to do is create two different CNAMES in Godaddy that will each point to the different service URL you provided. You also need to verify the domains/subdomains with each individual service before you can assign a domain.
See Azure documentation to create a custom domain.
Related
I have deployed 2 web application on a single azure web app using the virtual application, please refer screenshot below,
Now I want to point custom domain URL as,
main.mydomain.com to app1
and
api.mydomain.com to app2
is it possible? if yes how to achieve that? please help.
Otherwise, I will end up creating no of WebApps for each application? Then is that the only approach?
According to your description, you want visit main.mydomain.com and redirect to yourwebapp.azurewebsites.net/app1 and same with app2.
If so, you could use the following rule in web.config:
<rewrite>
<rules>
<rule name="RedirectTovirtualDirectory" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^main.mydomain.com$" />
</conditions>
<action type="Redirect" url="https://yourwebapp.azurewebsites.net/app1/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
I have an Azure website at site1.azurewebsites.net and a domain on GoDaddy for somesite.com
So I want to use my somesite.com domain to handle site1.azurewebsites.net I have followed Azure's instructions and set up
How would I change the URL it uses In Asp.net MVC Site ?
This is a DNS issue and fix.
Your AzureWebsite URL should be put down as the source for your CNAME record for your existing domain.
I.E # record points to site1.azurewebsites.com
When a user goes to your URL, they are delivered the content from the Azure URL, but still stay on the same URL.
Do not do the redirect answer with web.config, unless you want to change the URL of your site, to be the azure URL. A redirect is not the correct fix. Configuration of DNS records is
You could set the URL rewrite in your web.config file to redirect your Azure Web Site to custom domain name.
Here is an example code that helps you redirect to your custom domain.
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect rquests to default azure websites domain" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^yoursite\.azurewebsites\.net$" />
</conditions>
<action type="Redirect" url="http://www.yoursite.com/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
For more details, refer to this blog post.
This has probably been asked many times, but I have a purchased domain (through 1&1 if that matters) foobar.com. I have setup custom domains in Azure and domain to forward to an azure app service I built, and that is working fine when someone goes to foobar.com. What I am seeing is if someone goes to www.foobar.com. they get an ugly web app not found (an Azure screen). What do I need to setup to make this redirect work. Do I need to update the domain/azure in someway? I have the following rule in my Web.config
<rules>
<rule name="Redirect old-domain to new-domain" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.foobar.com$" />
</conditions>
<action type="Redirect" url="http://foobar.com/{R:0}" redirectType="Permanent" />
</rule>
</rules>
I always solve this with CNAME not through web.config. Take a look if you followed the steps described in here:
https://learn.microsoft.com/en-us/azure/cloud-services/cloud-services-custom-domain-name-portal
I host and html site in Azure CDN (under a with Premier paid Plan) so it gives me a Rules engine, which gives a lots of features to control the flow. I would like to have URL redirect and URL rewrite Azure CDN rules, please.
Example:
Given a site like www.example.com on which users can access see info as www.example.com/username, I've setup the following rules in IIS:
<rule name="rulex" enabled="true" stopProcessing="true">
<match url="." ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
So, how I can set the same rule in Azure CDN please? Is this possible? Any links to examples would be greatly appreciated :)
The following official documentation from microsoft docs explains the same
Azure CDN does not support URL Rewriting. It simply caches the URL requested (according to any query string or header caching rules set) and returns the cached response for subsequent requests for the same URL.
My azure web application (myapp.azurewebsites.net) is mapped to a custom domain (client1.mycompany.com).
I will be mapping it to some more custom domains (client2.mycompany.com, client3.mycompany.com etc.) one per each client.
In web application I am using
HttpContext.Current.Request.Url.Host
to get custom domain address which is accessing the application. But it is sometimes returning myapp.azurewebsites.net instead of custom domain.
Any idea how I can custom domain url in Azure in reliable way?
As Admir said in his answer the default *.azurewebsites.net binding cannot be removed, but it is very easy to prevent users from using this domain name for your site.
<rewrite>
<rules>
<rule name="Canonical Host Name" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="client1.mycompany.com" negate="true" />
</conditions>
<action type="Redirect" url="http://client1.mycompany.com/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
*.azurewebsites.net is not removable which means it is out of your control if someone will access your website through that DNS binding, which explains why you get that when you attempt to inspect HttpContext.Current.Request.Url.Host.
Only thing you can do is to choose to ignore requests coming directly to that binding, by redirecting user to:
Custom page (i.e. 404)
Some default custom domain