0

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
2
  • 1
    You can't use back-references with negative patterns. Try %{REQUEST_URI}. RewriteRule !^(login\.php|signup\.php)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] Commented May 16, 2014 at 15:46
  • @Deadooshka: That's a very valid point, post it as an answer below. Commented May 16, 2014 at 15:47

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

7 Comments

Stil getting the Redirect Loop... :( Any other ideas what may be causing it?
@NiltonFredericoTeixeira May be negative patterns not allow parentheses. !^login\.php$|^signup\.php$
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] ?
@NiltonFredericoTeixeira edited. negative patterns in mod_rewrite not documented, so we have many variants to test.
@NiltonFredericoTeixeira: Test in a new browser.
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.