通过Htaccess禁用SSL证书HTTPS重定向

时间:2018-12-01 10:13:08

标签: .htaccess ssl https

因此它重定向到https,但是由于我不再具有SSL证书,因此需要将其禁用,尝试删除Force SSL部分也没有执行相同的操作,因为force web www也没有进行任何更改< / p>

另一件事是,当我转到自己的网站时,它会自动添加www。两次wwww.www。(域名)

这是htaccess

<IfModule mod_expires.c>
  ExpiresActive on

# Your document HTML
  ExpiresByType text/html "access plus 0 seconds"

# Media: images, video, audio
  ExpiresByType audio/ogg "access plus 1 month"
  ExpiresByType image/gif "access plus 1 month"
  ExpiresByType image/jpeg "access plus 1 month"
  ExpiresByType image/png "access plus 1 month"
  ExpiresByType video/mp4 "access plus 1 month"
  ExpiresByType video/ogg "access plus 1 month"
  ExpiresByType video/webm "access plus 1 month"

# CSS and JavaScript
  ExpiresByType application/javascript "access plus 1 year"
  ExpiresByType text/css "access plus 1 year"
</IfModule>

Options -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]

### Force web (www) on all URLs

    RewriteCond %{HTTP_HOST} !^$
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteCond %{HTTPS}s ^on(s)|
    RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

### Force SSL (https) on all URLs

    RewriteCond %{HTTPS} off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

### Remove trailing slash from all URLs

    RewriteRule ^(.*)/$ $1 [R=301,L]

    RewriteCond %{HTTP_USER_AGENT} libwww-perl.* 
    RewriteRule .* ? [F,L]

    RewriteRule ^buy-([a-z0-9-]+)$ buy.php?game=$1 [NC,L,QSA]

# Redirect proper URL to SEO-friendly for buy.php

    RewriteCond %{THE_REQUEST} buy\.php\?game=([a-z0-9-]+)\s [NC]
    RewriteRule ^ buy-%1? [R=301,L]

# Internally link SEO-friendly with proper URL for buy.php

    RewriteRule ^buy-([a-z0-9-]+)$ buy.php?game=$1 [L]

# Redirect proper URL to SEO-friendly for sell.php

    RewriteCond %{THE_REQUEST} sell\.php\?game=([a-z0-9-]+)\s [NC]
    RewriteRule ^ sell-%1? [R=301,L]

# Internally link SEO-friendly with proper URL for sell.php

    RewriteRule ^sell-([a-z0-9-]+)$ sell.php?game=$1 [L]

# Redirect proper URL to SEO-friendly for testimonials.php (with pages)

    RewriteCond %{THE_REQUEST} testimonials\.php\?page=([0-9-]+)\s [NC]
    RewriteRule ^ testimonials/%1? [R=301,L]

# Internally link SEO-friendly with proper URL for testimonials.php (with pages)

    RewriteRule ^testimonials/([0-9-]+)$ testimonials.php?page=$1 [L]


# Redirect proper URL to SEO-friendly for recover.php (with code)

    RewriteCond %{THE_REQUEST} recover\.php\?code=([a-z0-9-]+)\s [NC]
    RewriteRule ^ recover/%1? [R=301,L]

# Internally link SEO-friendly with proper URL for recover.php (with pages)

    RewriteRule ^recover/([a-z0-9-]+)$ recover.php?code=$1 [L]


# Redirect proper URL to SEO-friendly for index.php (with order ID)

    RewriteCond %{THE_REQUEST} index\.php\?order=([a-zA-Z0-9-]+)\s [NC]
    RewriteRule ^ o/%1? [R=301,L]

# Internally link SEO-friendly with proper URL for index.php (with order ID)

    RewriteRule ^o/([a-zA-Z0-9-]+)$ index.php?order=$1 [L]




# Redirect proper URL to SEO-friendly for any standard page

    RewriteCond %{THE_REQUEST} \s/+(account|testimonials|contact|privacy|terms|cart|recover|faq|login|register|banned)\.php [NC]
    RewriteRule ^ /%1? [R=301,L]

# Internally link SEO-friendly with proper URL for any standard page

    RewriteRule ^(account|testimonials|contact|privacy|terms|cart|recover|faq|login|register|banned)$ $1.php [NC,L]

1 个答案:

答案 0 :(得分:0)

您的配置中可能有一个从http重定向到https的301重定向。简单地删除此重定向并重试将无济于事,因为301是永久重定向的代码,这意味着浏览器将记住此重定向,即它将访问https://而不是{{1} },因为缓存的重定向会这样说,甚至不会尝试访问http://

要解决此问题,您需要同时删除重定向和清除浏览器缓存-然后可以重试。是的,这会影响访问您网站的每个客户。由于无法从每个客户端清除浏览器缓存,因此最好安装新证书。拥有一个用户后,您便可以将所有用户从http://重定向到https://,过了一会儿,大多数浏览器都应该收到http://的信息,以便您删除重定向和证书。甚至更好的是,只留http://-像Let's Encrypt这样的CA为您提供免费证书。