Kod
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
Chciałbym, aby wybrane kontrolery i ich akcje były obsługiwane przez HTTPS. Posłużyłem się więc następującą zmianą
Kod
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} registration [OR]
RewriteCond %{REQUEST_URI} contact
RewriteRule ^(.*)$ https://domena.pl/$1 [R,L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} registration [OR]
RewriteCond %{REQUEST_URI} contact
RewriteRule ^(.*)$ https://domena.pl/$1 [R,L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
gdzie kontroler registration oraz contact są przekierowywane na HTTPS. Rozwiązanie działa, choć nie wiem czy to najlepsza forma, ale problem polega na tym, że na stronie tworzę linki typu
czyli będąc na stronie jako HTTPS zostanę również przekierowany na stronę poprzez HTTPS. Chciałbym jednak, aby pozostałe kontrolery były obsługiwane poprzez zwykły HTTP. Macie pomysł na rozwiązanie tego problemu?
EDIT (2009-04-29)
Rozwiązałem to póki co w ten sposób:
Kod
RewriteEngine on
# HTTPS redirect
RewriteCond %{HTTPS} off
RewriteRule ^/?registration|contact.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
# HTTP redirect
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/?registration|contact|css|images|js.*$
RewriteCond %{REQUEST_URI} !^/?index\.php$
RewriteRule .? http://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteRule !(\.gif|\.jpe?g|\.png|.ico|\.css|\.txt|js/.*)$ index.php [NC,L]
# HTTPS redirect
RewriteCond %{HTTPS} off
RewriteRule ^/?registration|contact.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
# HTTP redirect
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/?registration|contact|css|images|js.*$
RewriteCond %{REQUEST_URI} !^/?index\.php$
RewriteRule .? http://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteRule !(\.gif|\.jpe?g|\.png|.ico|\.css|\.txt|js/.*)$ index.php [NC,L]