停止重定向到https

时间:2015-03-24 14:29:09

标签: apache .htaccess redirect https virtualhost

一年前,我通过在.htaccess文件中包含以下内容将http重定向到https:

<IfModule rewrite_module>
# This checks to make sure the connection is not already HTTPS
RewriteCond %{HTTPS} !=on
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e.  http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</IfModule>

我评论了它。但是当我在浏览器中输入我的URL时,它仍然会重定向到https。我从.htaccess中注释了更多内容,如下所示&#34; ####&#34;:

# ----------------------------------------------------------------------
# Set variable for https to be used by domain rewrites
# ----------------------------------------------------------------------
# Source: http://www.askapache.com/htaccess/http-https-rewriterule-redirect.html
# Use Case: http%{ENV:https}://%{SERVER_NAME}%{REQUEST_URI}

#### RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
#### RewriteRule ^(.*)$ - [env=https:%2]

# ----------------------------------------------------------------------
# Prevent fully qualified domain names (trailing "." in HTTP_HOST)
# ----------------------------------------------------------------------
# Prevent possible issues such as duplicate content appearing search engines
# Read more at http://saynt2day.blogspot.ru/2013/03/danger-of-trailing-dot-in-domain-name.html

RewriteCond %{HTTP_HOST} \.$
#### RewriteRule ^.*$ http%{ENV:https}://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

# ----------------------------------------------------------------------
# Suppress or force the "www." at the beginning of URLs
# ----------------------------------------------------------------------

# The same content should never be available under two different URLs -
# especially not with and without "www." at the beginning, since this can cause
# SEO problems (duplicate content). That's why you should choose one of the
# alternatives and redirect the other one.

# By default option 1 (no "www.") is activated.
# no-www.org/faq.php?q=class_b

# If you'd prefer to use option 2, just comment out all option 1 lines
# and uncomment option 2.

# IMPORTANT: NEVER USE BOTH RULES AT THE SAME TIME!

# ----------------------------------------------------------------------

# Option 1:
# Rewrite "www.example.com -> example.com".

<IfModule mod_rewrite.c>
  #### RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  #### RewriteRule ^ http%{ENV:https}://%1%{REQUEST_URI} [R=301,L]
</IfModule>

<IfModule rewrite_module>
# This checks to make sure the connection is not already HTTPS
####  RewriteCond %{HTTPS} !=on
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e.  http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context
####  RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</IfModule>

但它仍然重定向到https。我从Apache虚拟主机文件中删除了<VirtualHost *:443>部分。我运行了sudo a2dissite,sudo a2ensite和sudo service apache2 restart。尽管如此,它仍然会重定向到https。

有人可以提供有关如何停止此重定向的建议吗?

0 个答案:

没有答案