Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Rewrite rules failing

aembytes
Level 4
Level 4

We want to apply two rewrite rules

1. Make uppercase to lower case

2. Forward http to https

 

We have this in our dispatcher but it's failing deployment and messing other scripts - can anyone point out what is wrong here?

 

RewriteMap lowercase int:tolower
RewriteCond $1 [A-Z]
RewriteRule ^/?(.*)$ /${lowercase:$1} [R=301,L]

 


RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution
Asutosh_Jena_
Correct answer by
Community Advisor
Community Advisor

Hi @aembytes 

 

Please use the below rule for upper case to lower case:

 

#Rule to ignore Case
RewriteMap lc int:tolower
RewriteCond %{REQUEST_URI} ^(.*)[A-Z]+(.*)$
RewriteCond %{REQUEST_URI} !.*\..*$
RewriteRule (.*) ${lc:$1} [R,L]

 

For HTTP to HTTPS on Apache please use below:

 

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule /(.*) https://%{SERVER_NAME}/$1 [R,L]

 

If you are running apache on 443 then the above rule is not required as the HTTP to HTTPS redirect can be handled at the ALB and apache will always receive request with HTTPs traffic. This is something that I prefer. 🙂

 

Thanks!

View solution in original post

2 Replies
Asutosh_Jena_
Correct answer by
Community Advisor
Community Advisor

Hi @aembytes 

 

Please use the below rule for upper case to lower case:

 

#Rule to ignore Case
RewriteMap lc int:tolower
RewriteCond %{REQUEST_URI} ^(.*)[A-Z]+(.*)$
RewriteCond %{REQUEST_URI} !.*\..*$
RewriteRule (.*) ${lc:$1} [R,L]

 

For HTTP to HTTPS on Apache please use below:

 

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule /(.*) https://%{SERVER_NAME}/$1 [R,L]

 

If you are running apache on 443 then the above rule is not required as the HTTP to HTTPS redirect can be handled at the ALB and apache will always receive request with HTTPs traffic. This is something that I prefer. 🙂

 

Thanks!

View solution in original post

Raja-kp
Level 7
Level 7

Hi - Can you please check rewrite logs to see how request is flowing ? Please enable the rewrite log in the configuration if not done.

"LogLevel info rewrite:info".

 

Then - please do the necessary configuration changes.