Link to home
Start Free TrialLog in
Avatar of AWI IT
AWI IT

asked on

Azure Web App - HTTP Redirect - web.config file help

Hello,

I have been trying to setup a Azure Web App with a custom domain name record and web.config file which can take care of http redirections for our domain.

I've configured the web app based on this technet article.

https://social.technet.microsoft.com/wiki/contents/articles/32229.azure-create-an-url-rewrite-azure-web-app.aspx

After following all the instructions I am unable to get the redirection to work. Here is the web.config file output which I am using.

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name=”projects.domain.com” patternSyntax=”ECMAScript” stopProcessing=”true”>
                    <match url=”http://projects.domain.com” />
                    <action type=”Redirect” url=”https://domain.sharepoint.com/sites/pwa/default.aspx" appendQueryString=”false” redirectType=”Permanent” />
                </rule>
        </rules>
        </rewrite>
    </system.webServer>
</configuration>

When I try to connect to projects.domain.com I receive the following message.

The page cannot be displayed because an internal server error has occurred.

Can anyone please help me understand what I am doing wrong here?

Thanks.
Avatar of Dan McFadden
Dan McFadden
Flag of United States of America image

Your match URL query is incorrect.  If you were to switch it from this:

<match url=”http://projects.domain.com” />

to this:

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

Open in new window


it should work.  This is directly from the documentation you provided.  Though this will redirect ALL traffic to this Azure instance, not just the FQDN because you have no condition setup.

Dan
Avatar of AWI IT
AWI IT

ASKER

Hi,

Yes I had that in originally and it still did not work. Same error message.

Any other ideas?
The match URL needs to (.*).

If is it still not working, you should try adding a condition statement, as recommended in the article you posted.

Dan
Also, which server is reporting the internal error?  The redirect may be functioning and it may be the destination website may be throwing the error.

Dan
What happens when you do directly to this URL:  https://domain.sharepoint.com/sites/pwa/default.aspx

Or whatever the destination of the redirect is.

Dan
Avatar of AWI IT

ASKER

I originally had exactly the same information listed pin the article in mt web.config file.

I changed it to see if it would work.

Still have not been able to get it working.
Can you answer my last question?

Dan
Avatar of AWI IT

ASKER

Okay I have changed the web.config file back to the original, plus the deafult.aspx. Still no joy :(

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name=”projects.domain.com” patternSyntax=”ECMAScript” stopProcessing=”true”>
                    <match url=”(.*)” />
                    <action type=”Redirect” url=”https://domain.sharepoint.com/sites/pwa/default.aspx” Jump appendQueryString=”false” redirectType=”Permanent” />
                    <conditions>
                        <add input=”{HTTP_HOST}” pattern=”projects\.domain\.com” />
                    </conditions>
                </rule>
        </rules>
        </rewrite>
    </system.webServer>
</configuration>
Avatar of AWI IT

ASKER

You wanna help me via live consultant? Go online.

You use teamviewer?
Avatar of AWI IT

ASKER

The destination URL works fine;

 https://domain.sharepoint.com/sites/pwa/default.aspx

This loads the main project online page.
Avatar of AWI IT

ASKER

One thing I didn't do is apply a certificate to the web app service. Do you think this could be causing an issue?

How can I see the logs for this web app?
Avatar of AWI IT

ASKER

Just want to confirm, my wwwroot only has the one file in it; web.config.

Should there be anything else uploaded, or should it work with just the single file?
I would place a default doc in the root of the website.  This way you can see that you are hitting the site.

As a test, disable the redirect (URL Rewrite), place a test html page in place.  Does this page get displayed correctly?

Dan
Avatar of AWI IT

ASKER

I removed the web.config file and copied in a default.html file with hello world inside it.

When browsing to the URL it worked. It displayed hello world in the browser.

What I did notice is that the URl for the site is http://projects.domain.com....what I'm trying to do is get it to re-direct and re-write the URL.

So if you put in your browser http://projects.domain.com > it redirects and changes the URL in the browser address bar to https://domain.sharpoint.com/sites/pwa/default.aspx.

At the moment it leaves http://projects.domain.com in the address bar... so maybe that need tweaking. ???
Avatar of AWI IT

ASKER

I'm looking for the equivalent of a 301 redirection. This is what dnsmadeeasy call it in their http redirection service.
I understand what it is that you are trying to do.  I just wanted to step back and verify that the website was functioning.

Now that the site has been verified as functional, we can try the redirect.

Just to be clear, you are placing real URLs in the web.config, correct?  I would create the redirect rule as mentioned in the article and test again.

Dan
Avatar of AWI IT

ASKER

When you say "real" URL's, yes I am placing my URL's in the web.config file that actually exist in reality. If I browse to https://domain.sharepoint.com/sites/pwa/default.aspx, it works and really exists and produces a website for project online project center.

I've created the web.config file exactly like it states in the article.

Here it is again, this is exactly what is in my web.config file now, apart from the word "domain" being swapped with my company domain name:

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name=”projects.domain.com” patternSyntax=”ECMAScript” stopProcessing=”true”>
                    <match url=”(.*)” />
                    <action type=”Redirect” url=”https://domain.sharepoint.com/sites/pwa/default.aspx” Jump appendQueryString=”false” redirectType=”Permanent” />
                    <conditions>
                        <add input=”{HTTP_HOST}” pattern=”projects\.domain\.com” />
                    </conditions>
                </rule>
        </rules>
        </rewrite>
    </system.webServer>
</configuration>
ASKER CERTIFIED SOLUTION
Avatar of Dan McFadden
Dan McFadden
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AWI IT

ASKER

Thanks for picking up on some errors there. Just want to confirm that the bracket is required in this section

pattern="{projects
Avatar of AWI IT

ASKER

After deleting the { bracket it is now working!!!

Well done Dan, I feel a little embarrassed that I didn't notice these errors myself.

Really appreciate all your help to get this working! :)
Oh, the bracket was my typo.  Glad its working now.

Dan
Avatar of AWI IT

ASKER

Thanks again Dan. Really appreciate you helping me out here.
No problem.  Can you close the question?

Dan