Search code examples
apache.htaccesshttp-redirectazure-webappsazure-custom-domain

Redirecting as proxy one subfolder of apache server to azure web app


I have a website on apache web server, and I would like one of subfolders to transparently redirect to azure web app.

  • mydomain.org -> regular apache page
  • mydomain.org/something -> regular apache page
  • mydomain.org/azure -> redirect to azure

However, I would need the url to stay on mydomain.org, so I would like - for example mydomain.com/azure/x/y to actually show result of azuredomain.org/x/y

I believe I can do it using .htaccess with rule: RewriteRule ^(.*)$ azuredomain.org/$1 [P]

However, this results in azure 404 error with suggestion that maybe "Custom domain has not been configured inside Azure", which is in fact correct.

Is it possible to configure 'mydomain.org ' as custom domain in azure, but only for one subfolder (mydomain.org /azure/) while allowing all other urls to map to apache server?


Solution

  • I managed to make it work:

    1. Create subdomain 'azure' pointing to folder 'azure'
    2. Add .htaccess to 'azure' folder with rule RewriteRule ^(.*)$ azuredomain.org/$1 [P]
    3. Add records to domain:
    • TXT / asuid.azure / [verificationID]
    • CNAME / azure / azuredomain.org
    1. In Web App settings add custom domain with subdomain: azure.mydomain.org