IIS Redirect To SubFolder - iis-7

I am trying to redirect a url to a subfolder, for example:
http://localhost/test is what the user will input, but I want that to redirect to http://localhost/test/public
I can't find any resource on the web, and most resources I found is on Apache which doesn't help.
Thanks.
PlayKid

In your web.config file in the Root of the site you would put something like this:
<?xml version="1.0"?>
<configuration>
<location path="test">
<system.webServer>
<httpRedirect enabled="true" destination="test/public" httpResponseStatus="Permanent" />
</system.webServer>
</location>
</configuration>

Related

Forward domain alias to a certain page

We have a domain (domain.com) that has an alias (alias.com). We are using Plesk and a Windows Server. In Plesk, alias.com is setup as an alias for domain.com.
We need that when people access to alias.com it goes to a certain page within the main domain, for example domain.com/this-page.html.
The web site is an ASP.NET MVC web site, in case we can do something using the web.config.
Is this possible? How can we do this?
Open web.config in the directory where the old pages reside
Then add code for the old location path and new destination as follows:
<configuration>
<location path="services.htm">
<system.webServer>
<httpRedirect enabled="true" destination="http://example.com/services" httpResponseStatus="Permanent" />
</system.webServer>
</location>
<location path="products.htm">
<system.webServer>
<httpRedirect enabled="true" destination="http://example.com/products" httpResponseStatus="Permanent" />
</system.webServer>
</location>
</configuration>

403 Forbidden error in Public Folder when I try redirection

I have ASP.NET site.
I can access to the public page, it's OK:
http://mysite/MyPublicFolder/index.htm
But I get 403 error when I try access to the folder:
http://mysite/MyPublicFolder/
MyPublicFolder contains index.htm.
I want Not allow users to browse directory, only Access to all pages in Folder.
We have the following error:
403 - Forbidden: Access is denied
You do not have permission to view this directory or page using the
credentials that you supplied.
<location path="/MyPublicFolder">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
I am using IIS 7.5, Windows Server 2008 R2.
Any suggestions?
UPDATE: web.config
Note: v1 is my Public Folder
<location path="v1">
<system.web>
<authorization configSource="Config\system.web.authorization.allow.config" />
</system.web>
<system.webServer>
<defaultDocument>
<files>
<add value="index.htm"/>
</files>
</defaultDocument>
<httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
<add wildcard="*" destination="/v1/index.htm" />
</httpRedirect>
</system.webServer>
</location>
<location path="v1/index.htm">
<system.webServer>
<httpRedirect enabled="false" />
</system.webServer>
</location>
First thing that is in my mind is default document. Do you have it set to 'index.htm'? Here is a bit more info.
It sounds a bit confusing. You are saying that you can open http://mysite/MyPublicFolder/index.htm what means that you have already got an access to all the pages located in this folder. I can just guess that you expect to get a redirect to index.htm file when you access a folder. Check out Default Document section in the IIS manager and make sure that index.htm is there.
UPDATE:
Looks like there are a lot of useless configuration in your web.config file. Change it to the following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="v1">
<system.web>
<authorization configSource="Config\system.web.authorization.allow.config" />
</system.web>
</location>
</configuration>
Now if you access your v1 folder it should automatically show you content of your index.htm file.

Redirect dead URLs to new URL in web.config

I have a few (4) links that need to be redirected in a .net website. For example, I need http://www.example.com/products/productname (which now longer exists) to redirect to http://www.example.com/products/productname.aspx.
How can I set up 301 redirects in the web.config?
Thanks!
Currently I have the following:
<location path="draft_root_beer">
<system.webServer>
<httpRedirect enabled="true" destination="~/products/draft_root_beer.aspx" httpResponseStatus="Permanent" />
</system.webServer>
</location>
If it is only adding ".aspx", I suggest you to use URL Rewriting, links will be better for SEO. Otherwise yous something like bellow:
<location path="productname">
<system.webServer>
<httpRedirect enabled="true" destination="http://www.example.com/products/productname.aspx" httpResponseStatus="Permanent" />
</system.webServer>
</location>

Web.Config 301 Redirect

I am trying to redirect a specific page from my old domain to a specific page on my new domain. The URLs look like the following:
http://blog.mysite.com/post/2012/05/hungry.aspx
to
http://mynewsite.com/hungry.aspx
I've looked to the Web.Config file to make this change, however the following code is not working:
<location path="post/2012/05/hungry.aspx">
<system.webServer>
<httpRedirect enabled="true" destination="http://mynewsite.com/hungry.aspx" httpResponseStatus="Permanent" />
</system.webServer>
</location>
When I visit my old blog page, it does no redirection and remains on the old blog page.
Am I missing something?
If http redirection is enabled on old server then you have to put new web config in folder post/2012/05/ with this content
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpRedirect enabled="true" destination="http://mynewsite.com/" httpResponseStatus="Permanent" />
</system.webServer>
</configuration>
btw. if all other options fails you could simply do that using Response.Redirect from code behind.

IIS7 301 Redirect Using web.config File...(Not Working) in case of Sub Folders and Files

IIS7 301 Redirect Using web.config File...
NOT WORKING....
<location path="ProductsAndServices/CustomProfessionalServices.aspx">
<system.webServer>
<httpRedirect enabled="true" destination="ProductsAndServices/business-video-platform.aspx" httpResponseStatus="Permanent" />
</system.webServer>
</location>
in above location tag i have tried to give a path using ASCII code Like "News/PressReleases/PressReleases.aspx" but still it is not working.
Then I tried to Give File Location it is also not working. as shown below
<location path="ULNotifier.zip">
<system.webServer>
<httpRedirect enabled="true" destination="Support/Resources.aspx?link=Support" httpResponseStatus="Permanent" />
</system.webServer>
</location>
But When I tried a single page it is working as given below,
<location path="Solutions.aspx">
<system.webServer>
<httpRedirect enabled="true" destination="Solutions/OnlineVideoPlatform.aspx?link=Solutions" httpResponseStatus="Permanent" />
</system.webServer>
</location>
Can Anybody fix this??

Resources