将每个组合重写为 WWW 和 https
我使用 helicon 的 isapi rewirte 。
我有这段代码用于非 www 到 www 重写:
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301]
对于非 www 到 www 部分工作正常...... 比我需要 www 如果它是在 http 上重定向到 https
RewriteCond %HTTPS (?!on).*
RewriteCond Host: (.*)
RewriteRule (.*) https\://$1$2 [I,RP, L]
我需要对此进行什么更改才能工作?
我得到 https://folder/index.asp 整个域名消失了
我尝试了其他相同的方法,但它不起作用,这里是:
RewriteCond %{HTTP:Host} ^(?!www\.)?(.*)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? https://(?%1www.)%2 [R=301]
如果我尝试domain.com,我得到https ://www。 如果我尝试 www.domain.com 我得到 https://www。
这意味着我解决了一半的问题!但为什么其余的网址不存在?!
i use isapi rewirte from helicon.
i have this code for non-www to www rewrite:
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301]
works fine for the non-www to www part...
than i need it the www if it is on http to be redirected to https
RewriteCond %HTTPS (?!on).*
RewriteCond Host: (.*)
RewriteRule (.*) https\://$1$2 [I,RP, L]
what do i need to change in this so it will work?
i get https://folder/index.asp
the entire domain is gone
i have tried samething else but it is not working as well, here it is:
RewriteCond %{HTTP:Host} ^(?!www\.)?(.*)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? https://(?%1www.)%2 [R=301]
if i try domain.com i got https://www.
and if i tried www.domain.com i got https://www.
what it means i solved half of my problem! but why the rest of the url is not there?!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的答案考虑 ISAPI_Rewirte 版本 3 的答案。
您会得到 https://folder/index.asp 因为您的主机值位于 %1 内,而不是 $1 内。
我建议:
My answer considers answer for ISAPI_Rewirte version 3.
You get https://folder/index.asp because your host value is inside the %1, not the $1.
I'd suggest: