Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS7 URL Redirection from root to sub directory [closed]

I am using Windows Server 2008 with IIS7. I need to redirect the users who come to www.mysite.com to wwww.mysite.com/menu_1/MainScreen.aspx. Here is the file structure I have for the projects:

-Sites  -Default Web Site   -Menu_1   -MenuService   -VscWebService 

I will really appreciate any help on this.

like image 298
user881148 Avatar asked Aug 10 '11 22:08

user881148


People also ask

How do I redirect the default website in IIS to virtual directory?

In IIS Manager, expand the server, expand Sites, and expand Default Web Site. Select the virtual directory, and verify Features View is selected at the bottom of the page. In the IIS section, double-click HTTP Redirect.

What is the difference between URL rewrite and redirect?

Simply put, a redirect is a client-side request to have the web browser go to another URL. This means that the URL that you see in the browser will update to the new URL. A rewrite is a server-side rewrite of the URL before it's fully processed by IIS.


1 Answers

Here it is. Add this code to your web.config file:

<system.webServer>     <rewrite>         <rules>             <rule name="Root Hit Redirect" stopProcessing="true">                 <match url="^$" />                 <action type="Redirect" url="/menu_1/MainScreen.aspx" />             </rule>         </rules>     </rewrite> </system.webServer> 

It will do 301 Permanent Redirect (URL will be changed in browser). If you want to have such "redirect" to be invisible (rewrite, internal redirect), then use this rule (the only difference is that "Redirect" has been replaced by "Rewrite"):

<system.webServer>     <rewrite>         <rules>             <rule name="Root Hit Redirect" stopProcessing="true">                 <match url="^$" />                 <action type="Rewrite" url="/menu_1/MainScreen.aspx" />             </rule>         </rules>     </rewrite> </system.webServer> 
like image 133
LazyOne Avatar answered Sep 28 '22 02:09

LazyOne