我在www.domain.com
上有一个网站,这是根(仅限).htaccess file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)\.(css|js|htc|pdf|jpg|jpeg|gif|png|ico)$ [NC]
RewriteRule ^(.*)$ index.php?path=$1 [QSA,L]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
我基本上正在对我的网址进行重写,所以所有内容都会通过index.php
页面。
如何在www.domain.com/login
,/register
和/settings
上强制 HTTPS(SSL)?因此,当我尝试访问http://www.domain.com/login
时,我应该立即重定向到https://www.domain.com/login
?
我搜索了SO而我找到了文件夹,所以如果我有文件夹/login
它会起作用,但在这种已经重写的网址的情况下不适合我。
答案 0 :(得分:0)
使用mod_rewrite你应该可以做这样的事情
RewriteCond %{SERVER_PORT} !443
RewriteCond %{REQUEST_URI} ^/register
RewriteRule (.*) https://www.domain.com/register [R]
答案 1 :(得分:0)
尝试:
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^login$ https://www.domain.com/login [R=301,L]
RewriteRule ^register$ https://www.domain.com/register [R=301,L]
RewriteRule ^settings$ https://www.domain.com/settings [R=301,L]