views:

27

answers:

1

So I am working on a project with multiple areas and we would like to configure IIS to rewrite our requests to make the urls nicer. I have been messing around with the URL rewrite module all day and I cannot get the desired results.

Example:

I currently have a long url like 'http://register.example.com/Registration/Register/New' where Area = Registration, Controller = Register... I would like the user to request the site by 'http://register.example.com' and it hits the register controller which I have configured to default to the 'New' action. Because I gave the subdomain of register, IIS knows that it will be using the 'Registration' area.

The finish url would be something like 'http://register.example.com/Register/Finish'

Is this possible?

Thanks, John

A: 

seeing as how you have marked MVC in your tags, you realize you can do this with a route.

    ''# Default Catch All MapRoute
    routes.MapRouteLowercase( _
        "Registration", _
        "{controller}/{action}/{step}", _
        New With {.controller = "Register", .action = "Registration", .step = "New"})

Then you just make a separate "website" in IIS to host the registration application.


PS... IMO sub-domains are overrated and often bad practice for the implementation you are describing. A sub-domain is used to describe a physical computer (IE your SQL server could be on sql.domain your web is on both domain and www.domain, and your email is on smtp.domain), it should not be used to separate sections of a single website. Also, many search engines index http:/subdomain.example.com separate from http://www.example.com, so your SEO values go way way down.

rockinthesixstring
I have mvc doing its default routing already where a controller will go to its index page by default. That is not the issue. I want to hide the Areas and use a subdomain instead (~/Area/Controller/Action?query). This way I can have multiple subdomains point to the same site but the user will not know since the Area will be hidden. foo.site.com is really pointing to foo.site.com/foo and bar.site.com is bar.site.com/bar
JKalberer
why do you want to separate out your site across subdomains? it can cause grief in other areas (like SEO).
rockinthesixstring
Well, it's not my website. I am just trying to do what the boss asked :).... I totally agree with the SEO problems. I need the subdomains so it is easier for customers to hit the separate parts of the site. These parts are distinct services which the user may or may not have access to. The only similarity between them all is the user account and login. How will the SEO fare if I have sub.site.com redirect to site.com/sub? I really appreciate the feedback.
JKalberer
sub.site.com and site.com are two totally different sites, so SEO is "spread out" across both. Sometimes the Boss is Wrong. I'd push back and say that `domain.com/register` and `domain.com/admin` and `domain.com/user`, etc is going to be a far better approach in the long run over having sub-domains for each section of the website. The only reason to separate out domains is like that of `wordpress.com` where each user gets their own "website"
rockinthesixstring