漂亮的URL无法在https协议上运行laravel 5.2 [英] Pretty urls not working laravel 5.2 on a https protocol

查看:69
本文介绍了漂亮的URL无法在https协议上运行laravel 5.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用本教程,漂亮的url在"http"上时仍在工作((未找到 在此服务器上找不到请求的URL/登录. wasamar.com.ng端口443上的Apache/2.4.7(Ubuntu)服务器,我做错了什么?

Pretty urls was working on when it was on "http" using this tutorial (https://laravel.io/forum/09-15-2015-removing-indexphp-from-url-laravel-5116) i figured it out but as i configured the "https" it stopped working (Not Found The requested URL /login was not found on this server. Apache/2.4.7 (Ubuntu) Server at wasamar.com.ng Port 443), what did i do wrong?

顺便说一句,我正在使用Ubuntu云服务器14.04

by the way i am using an ubuntu cloud server 14.04

这是我的虚拟主机配置/etc/apache2/sites-avalable/wasamar.com.ng.conf

This is my virtual host config /etc/apache2/sites-avalable/wasamar.com.ng.conf

<VirtualHost *:80>                                                                           
    # The ServerName directive sets the request scheme, hostname and port that           
    # the server uses to identify itself. This is used when creating                     
    # redirection URLs. In the context of virtual hosts, the ServerName                  
    # specifies what hostname must appear in the request's Host: header to               
    # match this virtual host. For the default virtual host (this file) this             
    # value is not decisive as it is used as a last resort host regardless.              
    # However, you must set it for any further virtual host explicitly.                  

    ServerName wasamar.com.ng                                                            
    ServerAlias www.wasamar.com.ng                                                       

    ServerAdmin info@wasamar.com.ng                                                      
    DocumentRoot /var/www/html/wasamar/public/                                           

    # Redirect permanent "/" "https://wasamar.com.ng/"                                   

    <Directory /var/www/html/wasamar/public/>                                            
             Options Indexes FollowSymLinks                                              
                     AllowOverride All                                                   
                     Require all granted                                                 
    </Directory>                                                                         

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,               
    # error, crit, alert, emerg.                                                         
    # It is also possible to configure the loglevel for particular                       
    # modules, e.g.                                                                      
    #LogLevel info ssl:warn                                                              

    ErrorLog ${APACHE_LOG_DIR}/error.log                                                 
    CustomLog ${APACHE_LOG_DIR}/access.log combined                                      

    # For most configuration files from conf-available/, which are                       
    # enabled or disabled at a global level, it is possible to                           
    # include a line for only one particular virtual host. For examplethe               
    # following line enables the CGI configuration for this host only                    
    # after it has been globally disabled with "a2disconf".                              
    #Include conf-available/serve-cgi-bin.conf                                           
    </VirtualHost>                                                                               

   <IfModule mod_ssl.c>                                                                         
   <VirtualHost *:443>                                                                          

    ServerAdmin info@wasamar.com.ng                                                      
    ServerName wasamar.com.ng                                                            
    DocumentRoot /var/www/html/wasamar/public/                                           

    #   SSL Engine Switch:                                                               
    #   Enable/Disable SSL for this virtual host.                                        
    SSLEngine on                                                                         

    <Directory /var/www/html/wasamar/public/>                                            
             Options Indexes FollowSymLinks                                              
             AllowOverride All                                                           
             Require all granted                                                         
    </Directory>                                                                         

    #   A self-signed (snakeoil) certificate can be created by installing                
    #   the ssl-cert package. See                                                        
    #   /usr/share/doc/apache2.2-common/README.Debian.gz for more info.                  
    #   If both key and certificate are stored in the same file, only the                
    #   SSLCertificateFile directive is needed.                                          
    SSLCertificateFile /etc/apache2/ssl/wasamar.com.ng/apache.crt                        
    SSLCertificateKeyFile /etc/apache2/ssl/wasamar.com.ng/apache.key                     
    </VirtualHost>                                                                               

    </IfModule> 

这是我的.htaccess文件

This is my .htaccess file

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

RewriteEngine On                                                        

# 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}]           

# Force SSL                                                             
RewriteCond %{HTTPS} !=on                                               
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]              

推荐答案

我认为应该首先将https重定向:

I think the https redirect should be first:

RewriteEngine On

# Force SSL
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
...

这篇关于漂亮的URL无法在https协议上运行laravel 5.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆