使用HttAccess laravel将https重定向到http

使用HttAccess laravel将https重定向到http,laravel,.htaccess,laravel-5,ubuntu-14.04,Laravel,.htaccess,Laravel 5,Ubuntu 14.04,我知道以前有人问过这个问题,但提供的答案对我来说并不适用 我的.htaccess代码如下 <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews -Indexes </IfModule> RewriteEngine On RewriteCond %{HTTPS} on RewriteRule (.*) http:

我知道以前有人问过这个问题,但提供的答案对我来说并不适用

我的.htaccess代码如下

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On
    RewriteCond %{HTTPS} on
    RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

    <Files ~ "^\w+\.(gif|jpe?g|png|docx)$">
    order deny,allow
    allow from all
    </Files>



## Server Defaults
ServerSignature Off
DefaultLanguage en-US
AddDefaultCharset utf-8

 ## Index Preferences
 Options All -Indexes
 IndexIgnore *

  ## GZIP Compression
  <IfModule mod_deflate.c>
    # Compress HTML, CSS, JavaScript, Text, XML and fonts
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
    AddOutputFilterByType DEFLATE application/x-font
    AddOutputFilterByType DEFLATE application/x-font-opentype
    AddOutputFilterByType DEFLATE application/x-font-otf
    AddOutputFilterByType DEFLATE application/x-font-truetype
    AddOutputFilterByType DEFLATE application/x-font-ttf
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE font/opentype
    AddOutputFilterByType DEFLATE font/otf
    AddOutputFilterByType DEFLATE font/ttf
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE image/x-icon
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/xml

# Remove browser bugs (only needed for really old browsers)
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    Header append Vary User-Agent
    </IfModule>

    ## Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 1 week"
</IfModule>


# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php5_module>
   php_flag asp_tags Off
   php_flag display_errors Off
   php_value max_execution_time 300
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 128M
   php_value session.gc_maxlifetime 525600
   php_value session.save_path "/var/cpanel/php/sessions/ea-php56"
   php_value upload_max_filesize 2M
</IfModule>
# END cPanel-generated php ini directives, do not edit

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php56” package as the default “PHP” programming language.
<IfModule mime_module>
  AddType application/x-httpd-ea-php56 .php .php5 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
<FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css)$">
<IfModule mod_headers.c>
    Header add Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>

选项-多视图-索引
重新启动发动机
在上重写cond%{HTTPS}
重写规则(.*)http://%{http_HOST}%{REQUEST_URI}[R=301,L]
#句柄授权头
RewriteCond%{HTTP:Authorization}。
重写规则。*-[E=HTTP\U授权:%{HTTP:AUTHORIZATION}]
#如果不是文件夹,则重定向尾部斜杠。。。
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_URI}(+)/$
重写规则^1[L,R=301]
#处理前控制器。。。
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]
命令拒绝,允许
通融
##服务器默认值
服务器签名关闭
美国的违约语言
AddDefaultCharset utf-8
##索引首选项
选项所有-索引
IndexIgnore*
##GZIP压缩
#压缩HTML、CSS、JavaScript、文本、XML和字体
AddOutputFilterByType DEFLATE应用程序/javascript
AddOutputFilterByType DEFLATE应用程序/rss+xml
AddOutputFilterByType DEFLATE应用程序/vnd.ms-fontobject
AddOutputFilterByType放气应用程序/x-font
AddOutputFilterByType放气应用程序/x-font-opentype
AddOutputFilterByType放气应用程序/x-font-otf
AddOutputFilterByType放气应用程序/x-font-truetype
AddOutputFilterByType放气应用程序/x-font-ttf
AddOutputFilterByType DEFLATE应用程序/x-javascript
AddOutputFilterByType DEFLATE应用程序/xhtml+xml
AddOutputFilterByType DEFLATE应用程序/xml
AddOutputFilterByType泄气字体/opentype
AddOutputFilterByType DEFLATE字体/otf
AddOutputFilterByType DEFLATE字体/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType放气图像/x图标
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType泄气文本/普通
AddOutputFilterByType DEFLATE text/xml
#删除浏览器错误(仅适用于真正旧的浏览器)
浏览器匹配^Mozilla/4 gzip纯文本/html
浏览器匹配^Mozilla/4\.0[678]无gzip
BrowserMatch\bMSIE!没有gzip!仅限gzip文本/html
头附加用户代理
##浏览器缓存
过期于
过期按类型映像/jpg“访问加1年”
过期按类型图像/jpeg“访问加1年”
ExpiresByType image/gif“访问加1年”
过期按类型图像/png“访问加1年”
ExpiresByType文本/css“访问加1个月”
过期按类型应用程序/pdf“访问加1个月”
ExpiresByType text/x-javascript“访问加1个月”
过期按类型应用程序/x-shockwave-flash“访问加1个月”
过期按类型图像/x图标“访问加1年”
ExpiresDefault“访问加1周”
#开始cPanel生成的php ini指令,不编辑
#手动编辑此文件可能会导致意外行为。
#要对此文件进行更改,请使用cPanel MultiHP INI编辑器(主页>>软件>>MultiHP INI编辑器)
#有关更多信息,请阅读我们的文档(https://go.cpanel.net/EA4ModifyINI)
php_标志asp_标记关闭
php_标志显示_错误关闭
php_值最大执行时间300
php_值最大输入时间60
php_值最大输入值为1000
php_值内存_限制128M
php_value session.gc_maxlifetime 525600
php_value session.save_path“/var/cpanel/php/sessions/ea-php56”
php\u值上传\u最大\u文件大小2M
#END cPanel生成的php ini指令,不编辑
#php——开始cPanel生成的处理程序,不编辑
#将“ea-php56”包设置为默认的“PHP”编程语言。
AddType应用程序/x-httpd-ea-php56.php.php5.phtml
#php——结束cPanel生成的处理程序,不编辑
标题添加访问控制允许源“*”
请注意:-我们使用的是Laravel 5.0 请注意:-我们目前在网站上没有ssl证书

在这件事上的任何帮助都将不胜感激

我也试过了

<VirtualHost *:443>
  SSLEnable

  RewriteEngine On
  RewriteCond %{HTTPS} on
  RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

</VirtualHost>

可耻的
重新启动发动机
在上重写cond%{HTTPS}
重写规则(*)http://%{http\u HOST}%{REQUEST\u URI}

非常感谢您在这方面提供的任何帮助

请尝试以下代码,将http重定向到https,并将非www重定向到www

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Start with www 
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
    RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]


    RewriteCond %{HTTP:X-Forwarded-Proto} !https 
    RewriteCond %{HTTPS} off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]


    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

</IfModule>

选项-多视图
重新启动发动机
#从www开始
重写cond%{HTTP_HOST}^www\。[北卡罗来纳州]
重写cond%{HTTP_HOST}^(?:www\)?(.+)$[NC]
重写规则^https://www.%1%{REQUEST_URI}[L,NE,R=301]
重写cond%{HTTP:X-Forwarded-Proto}!https
重写条件%{HTTPS}关闭
重写规则^https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301]
#如果不是文件夹,则重定向尾部斜杠。。。
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)/$/$1[L,R=301]
#处理前控制器。。。
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]
#句柄授权头
RewriteCond%{HTTP:Authorization}。
重写规则。*-[E=HTTP\U授权:%{HTTP:AUTHORIZATION}]

是立即发生还是需要等待?我需要遵循的任何其他步骤,我需要从https迁移到http,而不是强制https