本文介绍了没有搞乱本地主机的.htaccess的RewriteCond的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下一堆域:
- myDomain.de
- myDomain.com
- myDomain.co.za
- myDomain.org
- myDomain.com
- myDomain.com.na
什么是在htaccess的编写,使所有域的最短途径......
- 重定向到 https://www.myDomain.com 。即无论是输入域的,它会增加WWW和重定向到HTTPS和
- 仍然工作在我LOCALMACHINE(这样,如果有人类型的http://本地主机/网站/ src目录的它不会重定向到WWW网站?
解决方案
让我们来看看,如果这个工程:
RewriteEngine叙述上
#检查主机名包含。 (本地主机不会)
#检查主机名称以WWW
#检查主机名与.COM结尾
#检查连接是安全的
的RewriteCond%{HTTP_HOST} \。
的RewriteCond%{HTTP_HOST}!= svn.myDomain.com
的RewriteCond%{HTTP_HOST}!^ WWW [OR]
的RewriteCond%{HTTP_HOST}!\。com $ [OR]
的RewriteCond%{} HTTPS!=上
重写规则^ * $ https://www.myDomain.com/$0 [R = 301,L]
I have the following bunch of domains:
- myDomain.de
- myDomain.com
- myDomain.co.za
- myDomain.org
- myDomain.com
- myDomain.com.na
What is the shortest way to write in the htaccess, to make ALL domains...
- Redirect to https://www.myDomain.com. I.e. Regardless of the domain that is entered, it will add www AND redirect to https, and
- Still work on my localmachine (so that if someone types in http://localhost/site/src that it won't redirect to the www sites?
解决方案
Let's see if this works:
RewriteEngine On
# Check if the host name contains a . (localhost won't)
# Check if the host name starts with www
# Check if the host name ends with .com
# Check if the connection is secure
RewriteCond %{HTTP_HOST} \.
RewriteCond %{HTTP_HOST} !=svn.myDomain.com
RewriteCond %{HTTP_HOST} !^www [OR]
RewriteCond %{HTTP_HOST} !\.com$ [OR]
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://www.myDomain.com/$0 [R=301,L]
这篇关于没有搞乱本地主机的.htaccess的RewriteCond的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!