Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 567
  • Last Modified:

IIS7 Redirect Base URL to Subdirectory page?

Hello all,

I have a asp.net web application in IIS7 that I simply when the user hits the base URL path such as:

https://mysite.myhost.net/

I want it to go to:

https://mysite.myhost.net/sample/login/login.aspx

I have tried redirect and url rewrite in IIS7 but it is not working.
0
sbornstein2
Asked:
sbornstein2
  • 3
  • 3
1 Solution
 
nap0leonCommented:
Have you tried updating the default page to use a 301 redirect?


<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","https://mysite.myhost.net/sample/login/login.aspx");
}
</script>

Open in new window

0
 
nap0leonCommented:
If you have direct access to the machine running IIS, you can try these steps:
1    In internet services manager, right click on the file or folder you wish to redirect
2   Select the radio titled "a redirection to a URL".
3    Enter the redirection page
4    Check "The exact url entered above" and the "A permanent redirection for this resource"
5    Click on 'Apply'
0
 
sbornstein2Author Commented:
nap0leon I cant do it actually in the code as I don't have access to the code currently.  I can do something in the web config though or IIS directly.  I think something can be done in the web config with a rule etc. but need a example of using these sample URLs as you have it here in code.
0
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
nap0leonCommented:
Bump to make sure you saw my comment that I posted at the same time.

Good luck.
0
 
sbornstein2Author Commented:
2   Select the radio titled "a redirection to a URL". (I don't see this if I right click the file in IIS7 I only see edit permissions etc under Content View)
0
 
ivan_vaguninCommented:
Hi! You can put custom redirection logic in global.asax of your application.
Follow this example:
http://www.spsamples.com/2011/07/aspnet-redirect-requests-for.html
0
 
sbornstein2Author Commented:
thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now