在Apache重寫時遇到了一些問題。 我的整個網站都運行在SSL(在線商店)上,除了一個頁面(visit_us.php)和谷歌地圖API(因爲谷歌收取$$$$$的HTTPS訪問)。每當這個頁面包含不安全的內容(這對任何最終用戶聽起來都不好)時,這個頁面顯示一條消息,我實現了一個簡單的apache重寫規則切換到端口80,它工作正常。apache rewrite woes
RewriteEngine On
#redirect all http traffic to https, unless visit_us.php is requested
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/visit_us\.php
RewriteRule ^(.*)$ https://www.myurl.com/$1 [R=301,L]
#redirect https traffic for visit_us.php to http
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} ^/visit_us\.php
RewriteRule ^(.*)$ http://www.myurl.com/$1 [R=301,L]
然而,在整合Twitter的微件(只能工作在HTTP),我意識到我將不得不社交網絡頁面添加到工作在端口80 我以爲這是簡單的列表夠了,加上social.php頁面,上面的列表中,像這樣:
RewriteEngine On
#redirect all http traffic to https, unless visit_us.php or social.php is requested
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/visit_us\.php
RewriteCond %{REQUEST_URI} !^/social\.php
RewriteRule ^(.*)$ https://www.myurl.com/$1 [R=301,L]
#redirect https traffic for visit_us.php and social.php to http
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} ^/visit_us\.php
RewriteCond %{REQUEST_URI} ^/social\.php
RewriteRule ^(.*)$ http://www.myurl.com/$1 [R=301,L]
在我的網站,我明確地鏈接到HTTP,而不是HTTPS。然而,雖然它仍然適用於visit_us.php頁面,但social.php頁面似乎被忽略,並且請求不斷終止在端口443. 我在做什麼錯誤?
Apache questi ons幾乎總是偏離這個stackoverflow.com。總是有serverfault或網站管理員stckexchange站點。 –
我會銘記未來,謝謝。 – Stann0rz