Quantcast
Channel: URL Rewrite Module
Viewing all 2482 articles
Browse latest View live

Need Help with Rewrite URL and Maps

$
0
0

I have Rewrite Maps and two rules. The second rule I am trying to apply to the query-string-based URL is not working. All I am trying to achieve is to have URL with or without query string match the rewrite map key and then permanently redirect to the rewrite map value. Here is what I have....

REWRITE MAP KEY/VALUE PAIRS (SAMPLE)

<rewriteMaps>
<rewriteMap name="AWB_Rewrite_Map">
<add key="/about.asp" value="/about-us" />
<add key="/about-us/news/?id=40" value="/about-us/whats-going-on" />

...

THIS RULE IS NOT WORKING. MATCHES THE TOP PORTION AND DOESN'T WORK FOR CONDITION

<rule name="AWB_QSRewrite_Map" stopProcessing="true">
<match url="about-us/news/" />
<conditions logicalGrouping="MatchAll">
<add input="{AWB_Rewrite_Map:{URL}}" pattern="/about-us/news/\?id\=(\d+)" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" redirectType="Permanent" />
</rule>

THIS RULE WORKS FINE
<rule name="AWB_Rewrite_Map" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{AWB_Rewrite_Map:{URL}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" redirectType="Permanent" />
</rule>

Items in bold are related and not working. Any help would be appreciated. Need this ASAP...Thank you...


pdf HTTP Error 500.50 - URL Rewrite Module Error.

$
0
0

When i try to open my pdf file from my site then it will show the following error.

Static Rewrite

URL Rewrite is not working in IIS8

$
0
0

Hi,

I have two different alias names(alias1 and alias2) for same server.

When user enter alias1 then open webapplication1, if user enters alias2 then open webapplication2. i am trying to write url rewrite but it is not working. i am using iis8 and windows server2012.

Pls suggest on this issue.

Thanks,

gsmr

Uploading Web.config rises CPU Utilzation to 100%

$
0
0

I have Window Server 2008 R2 installed on VPS Intel Xeon L5609 1.87 GHz 2 GB RAM 64-bit processor. Whenever I upload web.config on my WordPress website root it works fine as I want to use URL Rewrite Module to hide http://*index.php/%postname/ but VPS's load shoots to 100% CPU utilization, under the process name "w3wp.exe *32" .

Please help me out and many thanks for your help and time in advance.

Following is my web.config script:

<?xml version="1.0"?><configuration><system.webServer><rewrite><rules><rule name="Main Rule" stopProcessing="true"><match url=".*" /><conditions logicalGrouping="MatchAll"><add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /><add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /></conditions><action type="Rewrite" url="index.php" /></rule></rules></rewrite></system.webServer></configuration>

Need help with multi rule URL rewrite code

$
0
0

I have a site where I'm trying to address a few URL issues through Web.Config and the URL Rewrite Module.  Unfortunately, when I make the changes, my AWS EC2 instance goes unstable and I'm not sure how to address, so I thought I ask for some help. 

For starters, this is what I'm trying to do.

http://www.mydomain.com/Default.aspx ->http://www.mydomain.com/ (Rewrite Domain to Default.aspx)

http://www.mydomain.com/Page.aspx ->http://www.mydomain.com/Page.aspx (Convert URL to lowercase)

http://mydomain.com -> http://www.mydomain.com (Canonical)

Of course any other thoughts are welcome too! 

The code I've used is below:

<rule name="Default Document"><match url="(.*)default.aspx" /><action type="Redirect" url="{R:1}" redirectType="Permanent" /></rule><rule name="rewrite to default.aspx"><match url="(.*)/?$" /><action type="Rewrite" url="{R:1}/default.aspx" /><conditions><add input="{REQUEST_FILENAME}" matchType="IsDirectory" /></conditions></rule><rule name="Convert to lower case"><match url=".*[A-Z].*" ignoreCase="false" /><action type="Redirect" url="{ToLower:{R:0}}" redirectType="Permanent" /></rule><rule name="CanonicalHostNameRule1"><match url="(.*)" /><conditions><add input="{HTTP_HOST}" pattern="^mydomain.com$" /></conditions><action type="Redirect" url="http://www.mydomain.com/{R:1}" /></rule>

Please note that I do server up images through a subdomain, for example images.mydomain.com so it needs to work with that as well.

ARR url rewrite delay IIS8 windows server 2012

$
0
0

Using windows Server 2012 and IIS8 I'm loosing 1sec on a simple rewrite to a backend server.

I enabled  traceing and what I found is that all the time is lost between headers start and headers end.

the backend server only responds with "hello world", if I bypass IIS the response time for the request is +- 350ms

....

18. -ARR_REQUEST_HEADERS_START 0ms 

=====> what happens here? losing almost a second?

19. -ARR_REQUEST_HEADERS_END 998 ms

....

Any hints?

Update: the rule is really simple, but maybe it'll help 

<rule name="dev" enabled="true"> <match url="bench.*" /> <conditions> </conditions> <serverVariables> </serverVariables> <action type="Rewrite" url="http://backendserver/{R:0}" /> </rule>

IIS Express and Custom URL Rewrite Providers

$
0
0

Hi folks,

I'm not sure if this is the right place to ask, but probably one of you pros here can help me or point me in the right direction.

So, I have written a custom provider for the IIS URL rewrite module. I followed the instructions given here to get me started, and build a provider that connects to an Oracle database, acquires some data there, does some things with it, and eventually provides a replacement URL. My custom provider can, after registering it in the GAC, be used in the full-fledged IIS without any problems and works just fine there.

HOWEVER, when working on website projects in Visual Studio, IIS Express is generally used for debugging. And, as can be read here, IIS Express contains the URL Rewrite module. Indeed, it supports (for example) normal regexp-based rules just fine, BUT ... and this is the question: Does it also support custom rewrite providers - just like the one I've written and mentioned above? Unfortunately, I have not yet been able to find a way to make my custom rewrite provider work in conjunction with IIS Express. If anybody knows if this is possible at all, and if so, how, then I'd highly appreciate any useful pointers in the right direction!

If all else fails, I fear I'd be forced to move all of my debugging to "real" IIS ... but I'd prefer to stay with IIS Express, as that's the much easier way to go with regard to all of my colleagues also working on the project.

Thanks in advance and greetings!
Nils

 


How to remove .svc from wcf rest service

Change 403 status code to 404

$
0
0

Hi,

I want to write an url rewrite so that if i get any 403 status code in the response it should changed to 404 like if I am trying to access any folder in iis it returns 403 I want to change it 404 because of security consideration

url not working

$
0
0

url rewrite in iis drives me nuts. (the troubles of using ms products Cry)

I have a url: http://www.example.co.uk/sub1/sub2/?size=D12

i have 2 url rules, i want rule 1 to run if the url doesn't contains a ? and i only want rule 2 to run if the url does contain a?

So far i have:

<rule name="Rewrite2" stopProcessing="true"><match url="(.+)\?" negate="true"/><conditions logicalGrouping="MatchAll" trackAllCaptures="false"><add input="{URL}" pattern="^.*\.(ashx|axd|css|gif|png|jpg|jpeg|js|flv|f4v|asmx|xamlx|asmx|xap)$" negate="true" /><add input="{QUERY_STRING}" pattern="(.+)\?+" negate="true" /></conditions><action type="Rewrite" url="default.aspx?Page={R:1}" appendQueryString="false" /></rule><rule name="Rewrite1" stopProcessing="true"><match url="(.+)" /><conditions logicalGrouping="MatchAll" trackAllCaptures="false"><add input="{URL}" pattern="^.*\.(ashx|axd|css|gif|png|jpg|jpeg|js|flv|f4v|asmx|xamlx|asmx|xap)$" negate="true" /><add input="{QUERY_STRING}" pattern="(.+)" /></conditions><action type="Rewrite" url="default.aspx?Page={R:1}&amp;Params={C:1}" appendQueryString="false" /></rule>

but this isnt working as expected. any help much appriciated.

Url Rewrite in web.config to Hide .php and .htm Extension on IIS 7 server

$
0
0

Hi,

I have a question about url rewrite in web.config to hide .php and .htm extension on IIS 7 server. 

It's my first time to use web.config file to rewrite url and since the hosting server is running IIS 7, my first time to do it on IIS 7 server too.

What I wanted to do is: I have two/three pages .php pages, like contact.php which has a contact web form in it. When the users click "contact.php" page, I don't want to show .php extension at the web url. I'd like it to showwww.test.com/contact instead of www.test.com/contact.php. Also, in the href link to point to the page, instead of wrtiing the code <a href="contact.php">Contact</a> which everybody can see it from source code, I'd like to have a href link as "<a href="contact">Contact</a> which will point to contact.php page, but without showing .php extension at web url and in the code either.

By googling, I got the following code by adding a web.config file in my root directory:

-----------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>

<rules>
<match url="profile.htm$" />
<action type="Rewrite" url="profile" />
<match url="contact.php$" />
<action type="Rewrite" url="contact" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

-----------------------------------------

However, as soon as I added the web.config file, I got 500 internal server error message. BTW, I'm a UI person, don't know much about server. Just wonder if I need to do other configuration to make this work. Or if the server guy at the hosting server should help me do something to make this work on his side?

Thanks much!

How to configure URL Rewrite run after Handler

$
0
0

I trying to integrate CA Site Minder Agent(running in IIS 7.5) and my web application (running in Glassfish 2). 

The request will go from Browser -> Site Minder Agent (call ISAPI in IIS) -> Integration Part->Application (Glassfish 2)

The Integration Part i use IIS ARR. Because IIS ARR use URL Rewrite to filter incoming request, but URL Rewrite alway run earlier than Handler, so the request never go through ISAPI. How can i configure to set URL Rewrite run after Handler. Thanks  in advance

Reverse proxy URL rewriting throw error 500.0

$
0
0

Hi,

I  setup a web server with IIS 7.5 ARR 3.0 as reverse proxy, and configured URL rewriting rules to redirect to internal web server but encountered HTTP Error (500.0/0x80004005); after further testing, I noticed static content e.g. html, img, css seem working fine but not .Net aspx pages. The reverse proxy server is not in the same domain as internal web server, and if I configure reverse proxy ARR and internal web site on the same sever it also works fine.  

Below is the web.config rule snippet,

            <rule name="Proxy">

                                <match url="(.*)" />

                               <action type="Rewrite" url="http://<internal website host name>/{R:1}" />

             </rule>

What could be the cause of the problem? Is it relevant to content compression? Must I turn off dynamic/static compression?  Thanks.

 

 

 

 

Rewriting issue with "subfolder" redirect

$
0
0

Hello,

i need some help. I'm trying to redirect a special URL. Server is 2008 R2 with IIS 7. I already installed URL rewrite Modul.

Link of the site should be  https://domain.com/abc/123

HTTPS-redirect works, but for the case someone is accessing domain.com/123  i got no idea how to solve it.

requested url: domain.com/123

should be rewrite to: https://domain.com/abc/123

This rule needs to be active, only if somebody is requesting this special domain.com (not for domain2.com etc.)

That'y my faulty try. It loops only to domain.com/abc/  and loses the 123

                <rule name="domain.com https redirect" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="^OFF$" />
                        <add input="{HTTP_HOST}" pattern="domain.com(.*)" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}/{R:0}" />
                </rule>
                <rule name="domain.com rewrite URL abc/xxx" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{QUERY_STRING}" pattern="abc(.*)" negate="true" />
                        <add input="{HTTP_HOST}" pattern="domain.com(.*)" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}/abc/{C:1}" />
                </rule>
            </rules>

Hopefully anyone can help me. Thanks!

Best regards

HAMIStechnik


URL Rewrite and ARR Behind a Firewall Issue

$
0
0

I have configured and setup my url rewrite and ARR with no issue.  The primary server is hosting the main website, I have a second web server hostng a blog site.  Users on teh inside of my firewall have no issues navigating to either pages in a few seconds.... everything works great.

The primary web server has been hosting our site for some time and responds well on the internet.  We are now testing going to the blog on the secndary server from the internet and it is slow (about 2 minutes to to load the blog landing page) and I can actually see the private IP address of the blog server as it is trying to load.  the primary site works fine.  I am curious if anyone know what Firewall Rules or Nat rules must be in place to get it to work faster, assuming that is what my problem is.  I have a call in to the FW vendor, and thought I would give this site a try as well.

Thanks

mc

Change to https:// and adjust domain if URL uses http:// and matches a particular path

$
0
0

I would like to redirect all calls to http://www.domain.com/csp/ to https://secure.doman.com/csp/ using URL rewrite running on IIS 8.5. I would like the URL on the browser to update accordingly. I cannot get it to work.

Below is the section of the web.config file with the rule

<rules><rule name="CSP to SSL" enabled="true" stopProcessing="true"><match url="^http://www.domain.com/csp/(.*)$" /><conditions><add input="{CACHE_URL}" pattern="^http://" /></conditions><action type="Redirect" url="https://secure.domain.com/csp/{R:1}" /></rule></rules>

Thank you.

Redirect to a farm when specific word

$
0
0

Hi I have AAR 3.0 on a Server 2012. I created some farms and redirection to these farms seems to be working. Among the farms I have web Server (domain.com) and RDGateway (domain.com/RDWeb). I am struggling to create a rule that will redirect to a RDGateway farm when the word "RDWeb" is recognized. Until now everythign is rerouted to the web server farm which gives page not found (not a miracle).

I created new farm for the RDGateway with URL Rewrite (wildcard) HTTP_Host = */RDWeb*, placed this rule above webserver url rewrite rule, but still nothing. The result is the same

Can you give me some suggestions?

ASP.NET Postback error under Reverse Proxy with IIS 8.5, URL Rewrite 2.0 and ARR 3.0

$
0
0
I would like to setup a reverse proxy in IIS but in my configuration I get problems with ASP.NET postbacks. When you click on any submit button of the proxied website then you get a 404 error. The URL in browser address bar is changed to the rewritten URL.

For example, the website that I need to proxy is http://website.com/host. Here http://website.com and http://website.com/host are separate web applications. Host is running as a virtual folder under website.com.

I want to access the Host from this URL: http://me.local/myhost. In IIS me.local is an asp.net web application and Myhost is added as another application as child of me.local. Everything works just fine as long as you don't click on submit button anywhere on the proxied website. Once you do this then you get to page http://me.local/host which results in 404 error. When you look at page's html source then form's action url is set correctly to /myhost

Why does the error happen? Is it possible to fix it in IIS, or do we need to make changes to the host application?

My server is running IIS 8.5. The host server is an old one with IIS 6, and web application can be asp.net 1.1 or asp.net 2.0.

The section with rewrite rules from web.config of "myhost" application is:

<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Route the requests for host" stopProcessing="true">
<match url="^(.*)" />
<conditions>
<add input="{CACHE_URL}" pattern="^(https?)://" />
</conditions>
<action type="Rewrite" url="{C:1}://website.com/host/{R:1}" />
<serverVariables>
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
</rule>
<rule name="hostToDefault" stopProcessing="true">
<match url="^" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
</conditions>
<action type="Redirect" url="default.aspx" appendQueryString="false" />
</rule>
<rule name="RedirectUserFriendlyURL1" stopProcessing="true">
<match url="^(.*)default\.aspx$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
</conditions>
<action type="Redirect" url="(.*)" appendQueryString="false" />
</rule>
</rules>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^http(s)?://website.com/(.*)" />
<action type="Rewrite" value="/{R:2}" />
</rule>
<rule name="NonhostRewriteRelativePaths" preCondition="ResponseIsHtml1">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^/(?!host)(.*)" negate="false" />
<action type="Rewrite" value="http://website.com/{R:1}" />
</rule>
<rule name="hostRelativePaths" preCondition="ResponseIsHtml1">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^/host/(.*)" negate="false" />
<action type="Rewrite" value="/myhost/{R:1}" />
</rule>
<rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1">
<match filterByTags="A, Form, Img" pattern="^(.*)myhost/default\.aspx$" />
<action type="Rewrite" value="{R:1}/myhost/default" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
<urlCompression doStaticCompression="false" doDynamicCompression="false" />
</system.webServer>
</configuration>

Rewrite Rule to redirect frm domain other than one page

$
0
0

I am new to Rewrite module . Any quick reply will be helpfull

I need to write rule for following condition and want to maintain protocol as it is.  

1) B.mydomain.com/one.html - dont do anything

2) B.mydomain.com/otherthanone.html (anything other than one.html), redirect to X.mydomain.com

i m also new to "logicalGrouping" if it will use to apply "AND" relationship between condition or not.

I tired following but it is not working to avoid one.html, it redirect all request of  B.mydomain.com to X.mydomain.com


<rule name="RedirectBRule" enabled="true" stopProcessing="true">
<match url="(.*)" />

<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^B\.mydomain\.com$" />
<add input="{REQUEST_URI}" negate="true" pattern="^(b.mydomain.com/one.html)$" />
</conditions>
<action type="Redirect" url="{MapProtocol:{HTTPS}}://X.mydomain.com/" logRewrittenUrl="true" appendQueryString="false" redirectType="Permanent" />
</rule>
<rewriteMap name="MapProtocol">
<add key="on" value="https" />
<add key="off" value="http" />
</rewriteMap>

Viewing all 2482 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>