Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to customize the domain in url based on the user requirement. That is
my main site is www.maindomain.com/Home
and what I need is
user 1 want to load the home page by www.user1domain.maindomain.com/Home
user 2 want to load the home page by www.user2domain.maindomain.com/Home
.
.
.
.
Like this based on customer need I want to load the Home page with the customized url. Can anybody tell me how should I do this? Only one time the file is hosted to server and it will be in the maindomain.com directory. I only need is for example if the user need to access the home page then he/she can access it through
www.maindomain.com/Home
OR
www.user1domain.maindomain.com/Home
OR
www.user2domain.maindomain.com/Home
Posted
Updated 4-Jan-16 17:47pm
v2

Will you own the domains user1domain.com and user2domain.com? If not then there is nothing you can really do. Those are top level domains that need DNS entries for routing.

What I would recommend doing is something like www.maindomain.com/user1/Home
 
Share this answer
 
Yes, you can surely make it happen. User 1 will navigate to user1domain.com and the next will use their own userxdomain.com (where x is the ID of the user), but only if you are willing to buy the domain name for $10+ per year. And according to me, this would be the worst way to start your business or application.

http://shop.domain.com/domains/[^]

What I would recommend is to use something like this, user1.domain.com and then provide a different URL for other users, like user2.domain.com. Many services are already using this mechanism, Tumblr, Wordpress, Blogger and so on. This mechanism is known as using "sub-domains". You can access the sub-domain using PHP or any other server-side language, ASP.NET would also work!

http://serverfault.com/questions/63200/how-do-i-create-subdomain-names-dynamically[^]
http://stackoverflow.com/questions/13875273/dynamic-subdomain-with-htaccess-not-redirect[^]

Another way of doing the same is using the URLs, friendly URLs, and then providing the parameters to the URLs. Like, domain.com/session/user1. This is a very simple way of doing anything. You can create a page "session" and then fetch the parameter "user1" and load his content in it.

The methods that I have provided you with are free of cost. You can create 1000+ users and provide them a different layout, page and so on, without having to pay another fortune cookie at all.
 
Share this answer
 
Thank you, that is a good idea.. But I have read that there is another way without buying the domain name. ie adding code in web.config file.

XML
<rules>
    <rule name="Rewrite subdomains">
        <match url="^/?$" />
        <conditions>
            <add input="{HTTP_HOST}" pattern="^(.+)\.foo\.com$" />
        </conditions>
        <action type="Rewrite" url="http://foo.com?barvalue={C:1}" />
    </rule>
</rules>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900