复杂的 mod_rewrite。有什么想法吗?
我想要 : - 如果使用 http,则从 http 切换到 https - 将子域重定向到index?o=子域(www除外) - 将子目录重定向到index?u=user
示例: http://www.mydomain.com 将被重定向到 https://www.mydomain.com
http:// subdomain.mydomain.com 将被重定向到 https://www.mydomain.com /index?o=subdomain
https://subdomain.mydomain.com 将被重定向到 < a href="https://www.mydomain.com/index?o=subdomain" rel="nofollow noreferrer">https://www.mydomain.com/index?o=subdomain
http://subdomain.mydomain.com/user 将被重定向到 https://www.mydomain.com/index?o=subdomain&u=user
https://subdomain.mydomain.com/user 将被重定向到 https://www.mydomain.com/index?o=subdomain&u=user
mod_Rewrite 是最好的选择吗?有什么想法吗?
提前致谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我现在没有时间测试它,但你可以尝试一下,看看它是否有效。有些事情可能会出现问题,所以如果您遇到问题,我很乐意稍后解决任何问题。另外,我认为我已经涵盖了您想做的所有事情,但如果我遗漏了什么,请告诉我。
编辑:我更新了下面的规则集。不过,我考虑了您的问题,尝试通过 TLS/SSL 提供子域时不会遇到问题吗?除此之外,以下之一应该执行您想要的操作(我希望这次没有错误):
如果您想要内部重定向:
如果您想要外部重定向:
I don't have time to test it right now, but you can try this and see if it works. There may be some potential for some things to go wrong, so if you have trouble with it I'd be happy to work out any kinks later. Also, I think that I covered everything you wanted to do, but let me know if I left something out.
Edit: I've updated the ruleset below. I thought about your question though, and aren't you going to have issues attempting to serve up your subdomains over TLS/SSL? That aside, one of the following should do what you want (without errors this time, I hope):
If you wanted internal redirection:
If you wanted external redirection: