• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

268
Views
Apache, Linux 2, Elastic Beanstalk - Rewrite http and www to https non-www

I am trying to get URL rewrites as noted in the question title. I created .platform/httpd/conf.d/ssl_rewrite.conf and with the below content, I was able to get http to https rewriting successfully.

RewriteEngine On
<If "-n '%{HTTP:X-Forwarded-Proto}' && %{HTTP:X-Forwarded-Proto} != 'https'">
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</If>

I am now trying to get the www to route to non-www. I have attempted to add an || clause to that If statement by changing it to <If "(-n '%{HTTP:X-Forwarded-Proto}' && %{HTTP:X-Forwarded-Proto} != 'https') || '%{HTTP_HOST}' !~ /^www\./", but that ended up creating some www.www.example.com routes.

Can someone provide any insight? Is creating multiple statements recommended?

about 3 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error