Laravel 5.3路由NotFoundHttpException

时间:2017-03-19 14:41:43

标签: php laravel .htaccess amazon-web-services ubuntu

我已在运行Ubuntu和php 7的AWS服务器上部署了我的Laravel 5.3应用程序。我已在/etc/apache2/sites-available/000-default.conf文件中创建了一个别名,如下所示:

Alias /myapp.dev /var/www/html/myapp/public/
    <Directory "/var/www/html/myapp/public/">
            Options Indexes MultiViews FollowSymLinks
            AllowOverride All
            Order allow,deny
            allow from all
            RewriteEngine On
            RewriteBase /var/www/html/myapp/public/
    </Directory>

但是当我尝试使用别名52.xxx.xxx.xx / myapp.dev访问时,我收到以下错误: enter image description here

当我使用完整的url访问public /目录时,它运行正常 例如。 52.xxx.xxx.xx/myapp.dev/public/login

我已启用 a2enmod ,而/ public目录中的.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}]

为什么我在我的aws服务器中获得 Route NotFoundHttpException 的任何想法,而不要忘记提到在我的本地Windows机器上运行php 5.6也运行良好的vhost。非常感谢您的想法。提前致谢

1 个答案:

答案 0 :(得分:-1)

试试这个.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>