Search code examples
azureapache.htaccesshttp-redirect

Custom domain won't retain path with Apache redirect on Azure App Service


my .htaccess works perfectly when testing locally, when I deploy to azure app service, and trying from customdomain.com/foo/content/bar.. --> newdomain.com, it wont retain path, if I use the azure's app service domain name which usually is: something-some-prod.azurewebsites.com the above works perfectly again with the path taken over.

.htaccess, example:

RewriteRule "^/?foo/foo/content/bar/content2/?$" "https://www.newdomain.com/foo/foo/" [L,R=301,NE]
  • the above content doesnt exist anyomre on the old domain, and i want to retain the foo/foo part, which is why i force this one.

my other rule, which is at the end:

RewriteRule "^/?(.*)" "https://www.newdomain.com/$1" [L,R=301,NE]

Not sure whats going on, anyone?

UPD: This is what i have on the newdomain host, .htaccess

    RewriteEngine On

# Handle URL Canonicalization 
RewriteCond %{HTTP_HOST} ^old-domain.com$ [NC]
RewriteRule ^(.*)$ https://www.old-domain.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^new-domain.com$ [NC]
RewriteRule ^(.*)$ https://www.new-domain.com/$1 [L,R=301]


# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Solution

  • SSL certificate was expired on the old domain.