Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simply URL Rewrite not working

I'm trying to set up an IIS URL Rewrite function to simply send any URL request to google (as a test):

            <rule name="Intercept" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
                <match url="(.*)" />
                <action type="Rewrite" url="google-homepage-url-here" appendQueryString="false" logRewrittenUrl="true" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="example.com$" />
                </conditions>
            </rule>

I'm using Rewrite rather than Redirect, because I need to hide the URL from the user. The above config works for Redirect but not for Rewrite, why is this?

When I hit http://example.com/blablabla I get a 404.4

My goal is for the user to be directed to the google home page.

I have ARR installed, any ideas?

like image 258
FBryant87 Avatar asked Oct 18 '22 05:10

FBryant87


1 Answers

If you want user to be directed to google home page, you should use redirect, not rewrite. That's not "hiding url from user" but processing on server side.

Without any logs I can only suggest that your IIS is trying to rewrite to google, asks it for some non existent page and obviously returns 404. It can happen if your website uses http and google server uses https, for example.

I think that you should also check difference between redirect and rewrite, this article is a good start.

like image 147
Jehy Avatar answered Oct 21 '22 05:10

Jehy