Laravel 5页面未在实时服务器上显示

时间:2016-01-02 20:28:23

标签: apache .htaccess laravel

要点:   - 我正在使用Laravel 5,apache和ubuntu   - mysite.com正在工作   - mysite.com/login适用于localhost,但不适用于实时服务器

我正在构建我的第一个网站,我的主页是“实时”(它正常运行)当我想创建一个“mywebsite / login”页面时,我的问题就出现了。当页面在我的本地计算机上运行时,我在实时收到404 Not Found错误。

我相信这种情况正在发生,因为我的.htaccess文件没有正确地重写我的文件夹结构。问题是我无法理解,因为这对我来说都是新的。

我的文档根目录是/ var / www / laravel / public 我的.htaccess在上面的文件夹中。 看起来像这样

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

  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)/$1 [L,R=301]

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

我在/ etc / apache2 / sites-available中有我的站点的虚拟主机文件 它的内容看起来像这样

<VirtualHost *:80>
  ServerName mysite.com
  ServerAlias www.mysite.com
  DocumentRoot /var/www/laravel/public

  <Directory /var/www/laravel/public>
    Options -Indexes +IncludesNOEXEC +FollowSymLinks +ExecCGI
    Allow from all
    Allowoverride All
  </Directory>
  RewriteEngine on

  <Directory /var/www/laravel>
    AllowOverride All
  </Directory>

  **A few more lines...**
</VirtualHost>

我还在服务器上启用了mod_rewrite。

我想我在某处有一个较小的“指向”错误,但我对这些文件的经验不足以查看它。有人能帮我一把吗?

由于

2 个答案:

答案 0 :(得分:1)

移动xyz上的所有文件(您的域/子域所映射的文件夹名称)文件夹

然后按照以下步骤操作

1 - 转到公共文件夹

2 - 复制.htacsses文件(这使您的路线有效)

3 -paste it in xyz folder

4将server.php更改为index.php

5 - 享受并快乐编码

这与hostgator.in共享托管工作正常。

答案 1 :(得分:0)

当您将代码从本地推送到服务器时,有时可能无法正常工作。为此,请尝试遵循以下命令。它对我有用,我希望它对每个人也有用。

$ sudo chmod 777 -R folderpath //To give 777 permission to your project
$ php artisan config:clear //To remove the configuration cache
$ php artisan view:clear //To remove the views blade cache    
$ php artisan route:clear //To remove the route cache
$ php artisan clear-compiled //To clear the compiled classes and services application cache

// If you use passport then: 
$ php artisan passport:install

// At last:
$ composer update