2017-03-16 95 views
0

漂亮的網址正在使用本教程的「http」時使用(https://laravel.io/forum/09-15-2015-removing-indexphp-from-url-laravel-5116)我想通了,但當我配置「https」時,它停止工作 (Not發現 所請求的URL /登陸此服務器上找到。 的Apache/2.4.7(Ubuntu的)服務器在wasamar.com.ng端口443),我做了什麼錯?漂亮的URL不能在https協議上工作laravel 5.2

由我使用Ubuntu的雲服務器14.04

這是我的虛擬主機配置/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 [email protected]              
    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 [email protected]asamar.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文件

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

+0

感謝注意到這些錯誤,我將在以後解決,但我的問題是,當你轉到https://wasamar.com.ng/login或https://wasamar.com.ng/register但是當你轉到https://wasamar.com.ng/index.php/login或https://wasamar.com.ng/index.php/register – udemethegrtman

+0

@GypsySpellweaver它正在移動,但在網絡上它有問題。 – udemethegrtman

回答

0

我認爲HTTPS重定向應該是第一:

RewriteEngine On 

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

我應該從.htaccess文件中刪除它還是OK? – udemethegrtman

+0

我已經提出了你的建議,但錯誤仍然存​​在。 – udemethegrtman