Scenario:
My website resolves to Aws ELB with 443 listener
Backend Target group is an EC2 instance with apache running on port 8080
Problem:
If I miss the trailing slash, the website does not resolve and when i put the trailing slash (/) everything works fine.
www.example.com/foldername <-- Does not work, returns url www.example.com:8080/foldername/ and resolution fails
www.example.com/foldername/ <-- Does Works fine
To check if everything fine on the backend I queried the EC2 instance IP on port 8080 with and without /
http://ec2_ip:8080/foldername and http://ec2_ip:8080/foldername/
both url with instance ip worked as expected
I'm guessing something fails between ELB and EC2 instance
Vhost Config:
Listen 8080
<VirtualHost *:8080>
ServerAdmin webmaster@localhost
Alias "/robots.txt" "/var/www/html/robots.txt"
DocumentRoot /var/www/html/rootfolder
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/rootfolder>
Options -Indexes
</Directory>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/script/(.*).js$ [NC]
RewriteRule .* /script/some.php?file=%1.js [L]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^/js/subscribe\?hash=(.*)
RewriteRule ^(.*)$ /script-v2/some.php?file=sub&hash=%1 [L]
RewriteCond %{REQUEST_URI}?%{QUERY_STRING} ^/js/worker\?hash=(.*)
RewriteRule ^(.*)$ /script-v2/some.php?file=sw&hash=%1 [L]
</VirtualHost>
Has anyone faced similar issue before?