HTaccess MOD_REWRITE Collision OF RULES: Force HTTPS & SEO Friendly

seo

#1

Hello fellas!

Im planning to force HTTPS and handle all SEO friendly URLs with index.php, but both rules seem to collide.

Chrome runs a 302 “Found” error when I add these two lines:

RewriteCond %{HTTP_HOST} !^ssl\.mydomain\.org$
RewriteRule ^(.*) https://mydomain.org%{REQUEST_URI}

Here is the full htaccess


<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTP_HOST} !^ssl\.mydomain\.org$
RewriteRule ^(.*) https://mydomain.org%{REQUEST_URI}

RewriteRule ^contacto$ /contacto.php [L]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /index.php

</IfModule>

Can you help me? Im quite confused and I think that Im missing the correct order of rules.


#2

Unless I’m missing something, aren’t you setting up an infinite redirect loop here? If the hostname isn’t ssl.mydomain.org then you’re redirecting to https://mydomain.org, which doesn’t match ssl.mydomain.org so then the request gets stuck in an infinite loop.

I would guess you want something like: