在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