[英].htaccess, Redirect to HTTPS on main domain and to HTTP on subdomain
Now, I have the following code in my .htaccess file 现在,我的.htaccess文件中包含以下代码
# redirect to https www
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)(builders-steps\.ru)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L]
# redirect to http subdomain
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^((?!www).+\.builders-steps\.ru)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
and it's working fine but main domain is now available on both https and http but I need the main domain to work only on HTTPS. 并且它可以正常工作,但是主域现在可以在https和http上使用,但是我需要主域只能在HTTPS上工作。 Subdomain is working fine with the current code (only on HTTP).
子域与当前代码(仅在HTTP上)可以正常工作。
Can you guys help me with advice? 你们能帮我提建议吗?
Thanks. 谢谢。
Not sure if it´s working. 不知道它是否有效。 Cannot try code here.
无法在此处尝试代码。
For rewriting All your main domain, try first redirecting the subdomain if it´s informed (higher restrictive) and later, if it´s not applied, you will check if for the main domain.
要重写您的所有主域,请尝试先重定向子域(如果有严格限制),然后再重定向(如果未应用),则将检查是否有主域。
# redirect to http subdomain
RewriteEngine On
RewriteCond %{HTTP_HOST} ^((?!www).+\.builders-steps\.ru)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^(?:www\.)(builders-steps\.ru)$ [NC]
RewriteCond %{SERVER_PORT} !443
RewriteRule ^(.*)$ https://www.builders-steps.ru/$1 [R,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.