We help IT Professionals succeed at work.

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

6,445 Views
Last Modified: 2017-05-14
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.
Comment
Watch Question

Dan McFaddenSystems Engineer
CERTIFIED EXPERT

Commented:
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

Author

Commented:
Hi,

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

Any other ideas?
Dan McFaddenSystems Engineer
CERTIFIED EXPERT

Commented:
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
Dan McFaddenSystems Engineer
CERTIFIED EXPERT

Commented:
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
Dan McFaddenSystems Engineer
CERTIFIED EXPERT

Commented:
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

Author

Commented:
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.
Dan McFaddenSystems Engineer
CERTIFIED EXPERT

Commented:
Can you answer my last question?

Dan

Author

Commented:
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>

Author

Commented:
You wanna help me via live consultant? Go online.

You use teamviewer?

Author

Commented:
The destination URL works fine;

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

This loads the main project online page.

Author

Commented:
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?

Author

Commented:
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?
Dan McFaddenSystems Engineer
CERTIFIED EXPERT

Commented:
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

Author

Commented:
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. ???

Author

Commented:
I'm looking for the equivalent of a 301 redirection. This is what dnsmadeeasy call it in their http redirection service.
Dan McFaddenSystems Engineer
CERTIFIED EXPERT

Commented:
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

Author

Commented:
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>
Systems Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

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

pattern="{projects

Author

Commented:
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! :)
Dan McFaddenSystems Engineer
CERTIFIED EXPERT

Commented:
Oh, the bracket was my typo.  Glad its working now.

Dan

Author

Commented:
Thanks again Dan. Really appreciate you helping me out here.
Dan McFaddenSystems Engineer
CERTIFIED EXPERT

Commented:
No problem.  Can you close the question?

Dan
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.