我有一個問題,我需要將我網站上的4個特定頁面重定向到他們的https安全版本。htaccess將4個特定頁面重定向到https
我現在有被重定向都example.com
和www.example.com
到https://example.com
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*\.)*example.com$ [NC]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://example.com/$1 [R]
一個htaccess文件,我需要的是像
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*\.)*example.com/page1.php$ [NC]
RewriteCond %{HTTP_HOST} ^(.*\.)*example.com/page2.php$ [NC]
RewriteCond %{HTTP_HOST} ^(.*\.)*example.com/page3.php$ [NC]
RewriteCond %{HTTP_HOST} ^(.*\.)*example.com/page4.php$ [NC]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://example.com/page1.php$1 [R]
RewriteRule ^(.*)$ https://example.com/page2.php$1 [R]
RewriteRule ^(.*)$ https://example.com/page3.php$1 [R]
RewriteRule ^(.*)$ https://example.com/page4.php$1 [R]
注意,我已經從刪除第三的RewriteCond線上面的代碼,因爲我不希望我的網站上的每個頁面都顯示https,而只是我特別聲明的頁面。
我怎樣才能解決這個問題呢?
PS也是,這條線是否涵蓋www.example.com和example.com?
RewriteCond %{HTTP_HOST} ^(.*\.)*example.com$ [NC]
我假設
^(.*\.)*
有什麼關係呢?
非常感謝Gerben,作品完美! – 2012-03-09 16:27:38