我在共享主机上有我的页面。 一般来说,该网站可以使用http和https访问。 该页面投放广告,而且大部分广告都不能使用https,因此我只希望通过https访问pipe理部分。
我想要的是:
http://myurl.com/auth -> https://myurl.com/auth http://myurl.com/admin -> https://myurl.com/admin https://myurl.com/allotherstuff -> http://myurl.com/allotherstuf
基本上所有的授权和承认请求都应该被redirect到使用ssl。 其他站点的请求应该从httpsredirect到http(如果使用https请求页面)。
我尝试了下面的.htaccess文件,这使得“auth”和“admin”无法访问(太多的redirect)。
<IfModule mod_rewrite.c> RewriteEngine On #Redirect other sites to http RewriteCond %{HTTPS} =on RewriteCond %{REQUEST_URI} !^/?auth.*$ RewriteCond %{REQUEST_URI} !^/?admin.*$ RewriteRule ^/?(.*) http://%{SERVER_NAME}/$1 [R,L] #Redirect auth and admin to https RewriteCond %{HTTPS} !=on RewriteRule ^/?auth/(.*) https://%{SERVER_NAME}/auth/$1 [R,L] RewriteCond %{HTTPS} !=on RewriteRule ^/?admin/(.*) https://%{SERVER_NAME}/admin/$1 [R,L] </IfModule>
是否有可能使用mod_rewrite来完成这个?
好的,如果要http到https那么请安装自己的唱歌证书
您可以在.htaccess文件中添加此代码
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^tset.com/tset$ [NC] RewriteRule ^/?$ "https://test.com/test" [R=301,L] </IfModule>