I want to set www.domain.com/folder
as folder.domain.com
. Both must run as same application.
Asked
Active
Viewed 105 times
1

Parag Meshram
- 8,281
- 10
- 52
- 88

Subin Jacob
- 4,692
- 10
- 37
- 69
-
This is not really clear. You want to access the content from `www.domain.com/folder` using the url `folder.domain.com`? – cheesemacfly Jun 04 '13 at 14:15
-
@cheesemacfly ya exactly... I don't want to create a domain for this... – Subin Jacob Jun 05 '13 at 03:32
-
Could this help: http://stackoverflow.com/a/15275533/1443490 ? – cheesemacfly Jun 05 '13 at 13:11
1 Answers
1
Add following rule in your web.config file -
<system.webServer>
<rewrite>
<rules>
<rule name="FolderSubDomain" stopProcessing="false">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(?!www)(\w+)\.domain\.com$" />
</conditions>
<action type="Rewrite" url="{C:1}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>

Parag Meshram
- 8,281
- 10
- 52
- 88
-
pointing to folder consider it as another application. I can't access the session state or cache from Main Application – Subin Jacob Jun 04 '13 at 11:49
-
I already created a subdomain folder.domain.com . Now IIS maps it into that folder. – Subin Jacob Jun 04 '13 at 11:50
-
@SubinJacob - try the alternate way then. I have removed new solution option. – Parag Meshram Jun 04 '13 at 11:52
-
-
Should I remove the site folder.domain.com that I created already before setting the web.config to the main app – Subin Jacob Jun 04 '13 at 11:54
-
if your url is folder.domain.com, `{R:1}` matches `folder` and `{C:1}` matches `domain.com`. So url `"{C:1}/{R:1}"` results in `domain.com/folder` – Parag Meshram Jun 04 '13 at 11:58
-
-
Read more about url rewriting. You will get an idea what exactly you need to do. http://coding.smashingmagazine.com/2011/11/02/introduction-to-url-rewriting/ – Parag Meshram Jun 04 '13 at 12:01
-
That means all subfolders can be accessed via subdomains. rite? Thanks for the guide – Subin Jacob Jun 04 '13 at 12:08
-
`The requested resource is not found.` this error shown while I added it to web.config – Subin Jacob Jun 04 '13 at 12:14
-
No. I installed rewrite module. (no config changes made). but still 404 error showing. However, I can access domain.com/folder. (testing on local network with domain configured locally) – Subin Jacob Jun 04 '13 at 12:33