I am want to redirect a url to another url by using IIS redirect. But i need to know how can i achieve this by using IIS redirect and also i need regular expression which redirect a specific URL to another url.
this is the Url which user will hit.
http://myurl.com/blog/social-media-page/
now i need to redirect above url to this url
http://blog.myurl.com/social-media-page/
how can i achieve this by using IIS redirect. I need to do this immediately.
For IIS 7+ update web.config of myurl.com to have following redirect
<?xml version="1.0"?>
<configuration>
<configSections>
..
</configSections>
<location path="social-media-page">
<system.webServer>
<httpRedirect enabled="true" destination="http://blog.myurl.com/social-media-page/" httpResponseStatus="Permanent" childOnly="true" />
</system.webServer>
</location>
I tested it and it works fine. All whats come to myurl.com/social-media-page is redirected (permanent redirect) to blog.myurl.com/social-media-page.
Related
I have followed the instruction reported here :
https://www.c-sharpcorner.com/UploadFile/francissvk/set-default-page-for-a-website-in-iis421/
What i would like to achieve, is that when user try to visit my site : "https://mysitename.com" it should be redirected to the home page ( "https://mysitename.com/pages/home.aspx").
I don't want to create a root Default.aspx page only to do the redirect, i would like to achieve this behaviour through Web.config.
As said, i tried the instruction in the above link, buy also tried the many solution proposed on this site that more or less suggest to add this configuration to Web.config :
<system.webServer>
<defaultDocument enabled="true">
<files>
<clear />
<add value="/Pages/Home.aspx"/>
</files>
</defaultDocument>
<handlers>
I have tried different variation of the path, i have tried :
<add value="/Pages/Home.aspx"/>
<add value="~/Pages/Home.aspx"/>
<add value="./Pages/Home.aspx"/>
<add value="Home.aspx"/>
But allways i get this message error :
403 - Access denied.
If i manually enter in the browser the full page url "https://mysitename.com/pages/home.aspx" then i get no issue (just to point out that the page exists and is working)
I don't understand what i am missing in the configuration
A default page or DefaultDocument in IIS can't do what you want.
It is a feature that defines which document is loaded when a user requested a URL pointing to a directory on the server without specifying an actual page.
The value field should be the name of a file in that directory such as index.html or home.asp, it can not point to files in other directories.
In your case you may be able to use the builtin HTTP Redirect feature, in the GUI enable it and point to 'pages', also check the Only redirect requests to... checkbox
In your root web.config this may look like this:
<system.webServer>
<httpRedirect enabled="true" destination="pages" childOnly="true" />
<defaultDocument enabled="true">
<files>
<clear />
<add value="Home.aspx"/>
</files>
</defaultDocument>
</system.webServer>
Another option is to use the IIS Rewrite Module which allows you to create more complex rules on how to redirect and rewrite requests. It should be faster because it does work without a HTTP redirect which does back to the browser, but you first need it install it and understand how to use it.
How to redirect url
from
www.example.com/file.html
to
www.example.com/folder/file.html
using .htaccess and web.config
I have been searching for hours and have found several topics but none works for us
For IIS:
Open web.config in the directory where the old page resides. Then add code in web.config there for the old location path and new destination as follows:
<configuration>
<location path="file.html">
<system.webServer>
<httpRedirect enabled="true" destination="www.example.com/folder/file.html" httpResponseStatus="Permanent" />
</system.webServer>
</location>
</configuration>
For apache:
Add in .htaccess the following line:
Redirect /file.html http://example.com/folder/file.html
My IIS setup has one site, bound to a domain. Let's call it: www.mydomain.com
The site folder itself is empty. This site hosts multiple applications and virtual directories. One of the applications is 'portal'.
What I want to do is accept any incoming request for www.mydomain.com or www.mydomain.com/ and redirect it to: www.mydomain.com/portal
I've got ARR and URL Rewrites up and running. I'm just not sure how to configure them for this.
A redirection rule like below will work.
Put the following web.config file to your web site's root folder. Or, update the existing one if you have.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="toPortal" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="/portal" redirectType="Found" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
You may want look at this tutorial to learn how to create url rewrite rules with IIS Manager. These xml nodes are not coming from my brain too.
I have a .net site on a shared host environment so I don't have access to other solutions that require access to the server.
If I put the following code in my current web.config, is it enough to do the 301 redirect to my-new-site.com? Thanks.
<system.webServer>
<httpRedirect enabled="true" destination="http://www.my-new-site.com/" />
</system.webServer>
HTTP Redirection is not available on the default installation of IIS 7. You have to add it in Common Http Features for the Web Server Role. Is it enabled on your shared host ?
The correct way to do a permanent 301 redirect is :
<system.webServer>
<httpRedirect enabled="true" destination="http://www.my-new-site.com/" httpResponseStatus="Permanent" />
</system.webServer>
the default is response status is 302 (Found). More infos here.
I have to port my web application from apache to IIS 7 and got into trouble with the proper configuration.
In the apache configuration, I configured some mod rewrite stuff (in order to communicate with an apache active mq) like this:
#Reverse-Proxy to ActiveMQ AJAX-Interface
ProxyPass /foo/bar/amq http://localhost:8161/foo/amq/
ProxyPassReverse /foo/bar/amq http://localhost:8161/foo/amq/
ProxyPassReverseCookiePath /foo /
I've tried to configure the IIS 7 by using ApplicationRequestRouting.
The rewrite rule in the request for replacing the /foo/bar to the localhost adress does already work, but I've some problems to define a rule for setting up the correct cookie path in the response.
I've already found an article about manipulating responses here.
For me, it looks like with II7 I can only manipulate the HTTP body of the response.
How can I manipulate the response header in a way to edit the cookie path?
The cookie path in the response header looks like this:
Set-Cookie: JSESSIONID=1lu7hn253csbh11jax27k2i072;Path=/foo
The Path should be edited to "Path=/".
Thank for your time and your help
Rolf
This should do it
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<outboundRules>
<remove name="Update Cookie Path" />
<rule name="Update Cookie Path">
<match serverVariable="RESPONSE_Set_Cookie" pattern="^(.*; path=/)foo$" />
<conditions />
<action type="Rewrite" value="{R:1}" />
</rule>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
Check the more detailed reference.