2016-04-21 80 views
1

我在routes.php文件中定义的任何路线之上的简单路线发现:Laravel路线不以https

Route::get('/test', function() { 
echo 'hello'; 
}); 

它工作时,通过访问HTTP,但它给:

The requested URL /test was not found on this server. 

当我尝试通过https访问时。

我在互联网上搜索了很多,但找不到任何解决方案。

我的主页正在加载http和https,但其他路径无效。我需要一些额外的配置吗?

编辑:

的.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}] 


</IfModule> 

请指引我。

Thanx。

+0

我认为这将在5.2甚至工作。 http://stackoverflow.com/questions/28402726/laravel-5-redirect-to-https – aldrin27

回答

0

我面临同样的问题,我通过简单修改我的.htaccess文件来解决它。通常这是我们的重写模块的问题。 试试这个希望它适合你。

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

    RewriteEngine On 

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

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

此外,请确保文件夹结构匹配本地和生产服务器。

+0

请看看我的.htaccess我需要改变它吗?因为我粘贴你的.htaccess并且它给内部服务器错误。 – user2517610

+0

用您的项目路径替换<您的项目路径> –

+0

只需在您的.htaccess文件中添加此行'RewriteBase <您的项目路径>' –