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>
Related
How to enable/disable web directory indexing in IIS 7? I am not able to find web.config file. But I can find applicationHand.config file where I saw this line: <directoryBrowse enabled="true" />
I created web.config file in the same folder and added the following. It's not working.
<configuration>
<location path="Secured">
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</location>
</configuration>
One more question I have is, is by default web directory indexing is disabled in IIS and Apache2 ?
I have a web app that I'm decommissioning and I'm trying to redirect all requests to the old app to a particular page (which shows a link to the replacement and a message advising users to update their bookmarks).
I've set up a HTTP Redirect in the web.config using the answer from this question: ASP.NET httpRedirect : redirect all pages except one and it works except for when the user enters the URL of the site's root folder omitting the trailing slash, in which case it goes to the next directory up the tree, for example:
Original site root: [domain]/foo/bar/
[domain]/foo/bar/specificpage.aspx redirects to [domain]/foo/bar/Default.aspx (OK)
[domain]/foo/bar/ redirects to [domain]/foo/bar/Default.aspx (OK)
[domain]/foo/bar redirects to [domain]/foo/Default.aspx (not OK)
Here's the relevant web.config:
<system.webServer>
<httpRedirect enabled="true" destination="~/Default.aspx" httpResponseStatus="Permanent">
<add wildcard="/" destination="Default.aspx" />
</httpRedirect>
</system.webServer>
<location path="Default.aspx">
<system.webServer>
<httpRedirect enabled="false" />
</system.webServer>
</location>
How can I get it to work when the user goes to [domain]/foo/bar?
For the record, I fixed this by setting the redirect URL to the absolute path of the file, including the virtual directory the site root sits in:
<system.webServer>
<httpRedirect enabled="true" destination="/foo/bar/Default.aspx" httpResponseStatus="Permanent" exactDestination="true">
<add wildcard="/" destination="Default.aspx" />
</httpRedirect>
</system.webServer>
<location path="Default.aspx">
<system.webServer>
<httpRedirect enabled="false" />
</system.webServer>
</location>
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>
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.
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>