我有一个指令设置在我的htaccess发送所有非httpsstream量到https
RewriteCond %{SERVER_PORT} ^80$ RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L] # These are used by the Zend Framework... RewriteCond %{REQUEST_FILENAME} \.(js|css|gif|jpg|png|swf)$ [OR] RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L]
我现在需要添加两个例外,以阻止他们被redirect到https – 一个用于mydomain.com/register/,一个用于mydomain.com/services/test/
任何人都可以帮我吗?
谢谢。
好的,有人帮助我使用它:
RewriteEngine On RewriteCond %{SERVER_PORT} !^443$ RewriteCond %{THE_REQUEST} !/services/test RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L] RewriteCond %{REQUEST_FILENAME} \.(js|css|gif|jpg|png|swf)$ [OR] RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteCond %{THE_REQUEST} /services/test RewriteRule ^.*$ index.php [NC,L] RewriteRule ^.*$ index.php [NC,L]
Zend框架重写规则导致了一个问题,但现在工作正常。
RewriteCond%{SERVER_PORT} ^ 80 $
RewriteCond%{REQUEST_URI}!^ mydomain.com / register / $
RewriteCond%{REQUEST_URI}!^ mydomain.com / services / test / $
RewriteRule。* https://% {SERVER_NAME}%{REQUEST_URI} [R,L]
只有在url与您不符的情况下,您才可以进行重写。
RewriteCond %{SERVER_PORT} ^80$ RewriteRule !^http://mydomain.com/(register|services/test).*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]