我将所有非www请求重写为www:
RewriteCond %{HTTP_HOST} !^www\.mydomain\.de$ RewriteRule ^(.*)$ http://www.mydomain.de/$1 [L,R=301]
但是…这不适用于https,所以我也希望没有www的所有https请求与www的https。 例:
https : // mydomain . de --> https : // www . mydomain . de https://mydomain.de/example --> https://www.mydomain.de/example
有人帮我在这里? 提前致谢!
你可以使用这个代码:
## add www to a domain name RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTPS}s on(s)| RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
这将执行: