Home From http to https - htaccess and URL rewrite - Too many redirect error
Reply: 1

From http to https - htaccess and URL rewrite - Too many redirect error

DevTen
1#
DevTen Published in 2018-01-12 10:33:35Z

I have a site with the following working code in .htaccess to get friendly URLs:

RewriteEngine On
RewriteRule ^([^_]*)_([^_]*)\.html$ /?s=scheda&id=$1&slug=$2 [L]
RewriteRule ^([^/]*)\.html$ /?s=$1 [L]

Since I installed a SSL certificate, I need to update my .htaccess to redirect http contents to https. I found this code:

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

And I tried to add it to my .htaccess:

RewriteEngine On
RewriteRule ^([^_]*)_([^_]*)\.html$ /?s=scheda&id=$1&slug=$2 [L]
RewriteRule ^([^/]*)\.html$ /?s=$1 [L]

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

but I get a "Too many redirect problem" error.

What's wrong?

Thanks a lot.

Eugène Adell
2#
Eugène Adell Reply to 2018-01-12 15:44:04Z

This error indicates you are looping, and I can see only one rule that could loop :

RewriteRule ^([^/]*)\.html$ /?s=$1 [L]

This redirects a.html to ?s=a.html which matches this same rule.

But it shouldn't work in http too. Can you confirm ?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.294552 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO