How to Route URL from one domain to another - asp.net

I am an C# ASP.NET developer. I am trying to route URL from one domain to another using Godaddy IIS Virtual dedicated server or Dedicated server for ASP.NET.
For example I have a website application for client_A in my server which is intended to be use by multiple clients with different products.
An example URL: www.myserver.com/client_A/product/bear/?productid=1 or using pretty URL www.myserver.com/A_Application/product/bear/1
I would like to setup for my client to point to client_A using his/her domain.
My Client example URL will be: www.hisserver.com/product/bear/?productid=1 or using pretty URL www.hisserver.com/product/bear/1
Thanks!

The simplest solution would be for you client to set up their domain to simply point to your server, then use Apache virtual hosts to point that domain to the directory in question. I'm not sure if godaddy allows multiple virtual hosts like that, so you could also do it with a mod_rewrite based on the incoming Host.

Related

Webflow with self hosted ghost blog

Is there a way to run webflow & ghost together where - https://example.com/* is served by webflow and https://example.com/blog/* is served via my self hosted ghost server.
How do I put the IP of my ghost server in my domain's DNS record?
Or is there any other way to do this?
You could use subdomains instead of an extended URL.
Reference blog.example.com to the IP address of your ghost server.
To reference:
Connect a custom domain to the webflow site.
Go to the DNS manager of the custom domain.
If you have an IP address for the ghost server, then:
Add an A record with NAME = [subdomain] (here [subdomain] = blog) and Value = [IP address]
else If you have a domain name for the ghost server, then:
Add an CNAME record with NAME = [subdomain] (here [subdomain] = blog) and Value = [Domain Name]
You can only achieve this if you have an active webflow hosting using
a paid site plan which enables you to add a custom domain.
I would not recommend using a subdomain for your blog, for SEO reasons.
So if you want to use your hosted Webflow site in combination with a (own hosted) Ghost blog on the same domain name, for example on yourdomain.com/blog/ one way of achieving this by setting up a reverse proxy.
Your can read the whole set up here:
https://signoz.io/blog/webflow-ghost-subdirectory/
You would need to setup an independent reverse proxy server - using a web server such as Nginx or Caddy. You would then point your root domain to this server and reverse proxy to both your Webflow site and your Ghost site depending on the URL route.
Alternatively you could try to do this using Cloudflare Workers (Google for "using cloudflare worker as reverse proxy") or for a no code / managed solution you could try a service such as HostForward which does it all for you.

How to configure URL Redirect in Azure DNS Zone

We have multiple websites under Azure DNS Zone
ourbusiness.net
Given multiple Web Apps like So:
foo.ourbusiness.net
bar.ourbusiness.net
We would like to add URL redirects(Correct term?) such that navigation to the following:
foos.ourbusiness.net
thafoo.ourbusiness.net
morefoo.ourbusiness.net
all redirect to:
foo.ourbusiness.net
Would need the same for other apps like bar, baz etc, not just foo.ourbusiness.net.
We do not want an alias, the browser navigation needs to navigate to foo.ourbusiness.net in the browser URL.
I think it is possible using a combination of multiple A Records and a Ptr record. This would require a static IP or Virtual IP address(however that works.)
We use SSL.
What is the most direct way to accomplish above requirement in Azure? Thx..
According to your request, I think the most direct way is to set multiple A records.
It does need a IP address for the Web App and this solution need some cost. However,
NOTE: The IP address may change if you delete and recreate your web app, or change the web app mode back to free.
You can find more details about how to get an IP for Web app and in this document: Map an existing custom DNS name to Azure Web Apps
So,if you worry about this, I recommend you to configure CNAMEs .
Based on this requirement "We do not want an alias, the browser navigation needs to navigate to foo.ourbusiness.net in the browser URL." you need a HTTP redirect to tell the browser to navigate to a different address, i.e. foo.ourbusiness.net. That's not provided by Azure DNS but you could look at something like Azure Functions to create a HTTP reply with the correct HTTP return code etc.

how to create sub-domains

i am going to create some sub-domains on my website.
when i create a sub-domain i must define a directory that sub-domain will refer to newly created sub-domain. but i want a different solution.
i want to detect when a user enters a URL , which sub-domain is used and then do some operation for each special sub-domain.
for example if website user entered a.mysite.com
i extract "a" sub-domain from URL and then without redirecting webpage i load some data in page.
please help me how i do these,on both web-server and localhost?
In general your application doesn't care about the host name, so you have to configure your IIS to handle all requests.
Production only: Create a wildcard DNS record for your domain (e.g. *.domain.tld)
Your IIS site should have no explicit bindings, so that ALL incoming requests hit this application (other sites should still work fine!).
After this you can check the HttpContext.Current.Request.Url and extract the requested subdomain.

ASP.NET multi-Tenant Application

I have an Asp.net application 3.5. I want to be able to allow multiple/ different clients to access the same application but using different URL's. I have already managed to configure the database to allow this.
So here's the main part.
I want to host my application in a domain say...
wwww.myapplication.com
then allow different client to access the same application using
1) www.clientOne.myapplication.com
2) www.clientTwo.myapplication.com
Also the client subdomains i.e(clientone.myapplication.com and clienttwo.myapplication.com)
should be autocreated by the client upon registration.
How can I achieve this..Your help will be greatly appreciated
A good example of how I want my application to work is
www.quickschools.com
I finally found out the solution that I wanted, so I thought I would share with you my finding. It turns out I needed to create a web application from another running Asp.net web application (From C# Code)
This tutorial by Robbe Morris was really helpful if you need to get started on this.
Another article you might want to check out is this one.
To have different url's using the same application, i would use "301 redirect" subdomains. I'm not really sure how to have a webapp create these subdomains.
I think the way to do this is to make the website the default website on the server i.e. configure so all requests to the servers IP hit this website (unless the header matches another website that explicitly looks for it). You do this just by not specifying a header on the IIS settings (only an IP address and a port number) - you can only do this for one site per IP address/port combination on the server.
Then look at the request url in the website to determine which domain was requested.
This way there is no need to 'create' subdomains... but you do need to reject all request to a domain that you don't want to recognize.
If you can't do this then you would need to adjust the IIS metabase from the application - not impossible - but a very risky and probably a bad idea.
The common case is that you'll have to configure a new virtual site for each of your new tenants during account provisioning. See Creating a New Virtual Server on how to achieve this programatically. Some though argue (with convincing arguments...) that spinning up an appdomain for each tenant is a waste of resources and one should use routing in the application that inspect the HOST header, see Multi-tenant ASP.NET MVC – Introduction.
Configuring IIS/ASP to respond to your tenant sub-dmains is the easy part. The real problem will be to configure DNS for your tenants, and that depends on your DNS solution.

How do I allow a user to use their own domain name for a hosted service?

I am working on an ASP.NET MVC web app that allows people to publish content, but other than publish the content to a remote server, I want to allow people to use their domain name directly. For example, the user "Tom" can have his domain name TomSite.com point to http://www.mywebapp.com/user/tom, but the sub path will also be mapped. For example, TomSite.com/path will be mapped to www.mywebapp.com/user/tom/path, and this is transparent to the web visitor. The visitor will never see "mywebapp.com" anywhere on TomSite.com.
I think Smugmug.com provides such service, to allow people to use their own domain name for the photo portfolio. I want to achieve the same result.
How can I do this? Thanks!
This require multiple steps.
First you have to find out how your users will configure their domain to have a CNAME record for you site. You can archieve this in a number of ways where the best is education. Making partnerships with hosting providers requires a great deal of volume.
In IIS this will require you to either add each host name manually (however this could also be archieved through scripting) or have a dedicated IP address only for you site.
There is also a need for the domain to be associated with an account. The user has to add this themselves and you would probably add a check in the interface which confirms the domain is pointed at your server. The code for this would look like (remember to include the System.Net namespace).
if (Dns.GetHostEntry("www.user.example.com").HostName == "www.example.com")
{
// www.user.example.com is a CNAME for www.example.com
}
In you ASP.NET MVC project you need to implement routes for this particular purpose. Create a custom class inheriting from Route which also takes the domain into account.
Smugmug (who you mentioned) get their users to setup a CNAME record that will alias the url for the user's personal photo section. For most users this will probably require them contacting their host or looking up help files in order to get it all setup.
So, while www.tomsite.com could transparently serve up pages hosted at www.mywebapp.com the users will have to put some kind of effort in. To make it a completely seamless you will need some kind of arrangement with the users web host (Smugmug appear to have such an arrangement with GoDaddy).
I doubt you will be able to setup such integration with all the web hosts out there, so the only complete solution would be to host the websites of your users yourself (I do not know enough about your wider situation to determine if that is a reasonable solution).
Note: setting up an alias on your own web server (aka url rewriting) will not work, unless you host their site yourself, as obviously people fetching from your user's domain will not arrive at your server in the first place.
Have each customer's friendlyname pointed at the external ip address of your webserver.
Use IIS to resolve the friendlyname specified in the host header request to the logical website you want delivered to that friendlyname. IIS will happily map both a website and a virtual folder to the same folder in the file system. Create a website for each customer. Then bind that website to the customer's friendlyname.
Remember to map the default website only to your own friendlyname(s). If you leave it in promiscuous mode (mapped to "*") results will be unpredictable.
To set host header mapping
Select Default Web Site under the Sites node. In the Actions pane at top right click on Bindings... to open the Site Bindings dialog. There will be a list of bindings, probably containing a single entry that says http * 80. Select this and click the Edit... button. Set Host name to your own friendlyname.
Run IIS7 Manager and for each customer site create a website under the Sites node. Set both file path and host header binding while you are creating each web site. Obviously the host header binding (host name) should be that customer's friendlyname.
Just make a new record in your webserver setting tomsite.com directly to your mywebapp.com/user/tom/ path ?
See it like an alias :)
Ofcourse, since you're asp.net/windows based, i think you'll have to digg deep into IIS to automate this kind of stuff. If you were on apache it would be adding 3 simple lines to httpd.conf.

Resources