Basically I have this code on my htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule ^ http://www.example.com%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(login.php|signup.php)$ https://%{HTTP_HOST}/1ドル [R=301,L]
RewriteCond %{HTTPS} on
RewriteRule !^(login.php|signup.php)$ http://%{HTTP_HOST}/1ドル [R=301,L]
It was supposed to send the user to a SSL Connection. But it keeps having a redirect loop. What Am I doing wrong?
asked May 16, 2014 at 15:32
Nilton Frederico Teixeira
752 silver badges8 bronze badges
1 Answer 1
You can't use back-references with negative patterns.
RewriteRule !^login\.php$|^signup\.php$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
or this
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !login\.php$
RewriteCond %{REQUEST_URI} !signup\.php$
RewriteRule . http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
answered May 16, 2014 at 15:48
Deadooshka
4786 silver badges8 bronze badges
Sign up to request clarification or add additional context in comments.
7 Comments
Nilton Frederico Teixeira
Stil getting the Redirect Loop... :( Any other ideas what may be causing it?
Deadooshka
@NiltonFredericoTeixeira May be negative patterns not allow parentheses.
!^login\.php$|^signup\.php$Nilton Frederico Teixeira
Now the redirect loop occours only in the login and signup.php pages. We're getting somewhere, thanks, there is some mistake in this line:
RewriteRule ^(login.php|signup.php)$ https://%{HTTP_HOST}/1ドル [R=301,L] ?Deadooshka
@NiltonFredericoTeixeira edited. negative patterns in mod_rewrite not documented, so we have many variants to test.
anubhava
@NiltonFredericoTeixeira: Test in a new browser.
|
%{REQUEST_URI}.RewriteRule !^(login\.php|signup\.php)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]