繁体   English   中英

找到 Laravel 5.6 '/' 路由,但未找到其他路由 AWS EC2

[英]Laravel 5.6 '/' route found but other routes not found AWS EC2

我是 laravel 和 AWS 的新手。 我正在尝试在 AWS EC2 apache 服务器上运行我的应用程序。 我的应用程序在本地系统中运行良好,但是一旦我尝试在 AWS 上上传代码,只有索引路由(即“/”)运行良好。 对于其他路线,它给了我NOT FOUND错误。 如果我尝试运行应用程序 /index.php/login 它正在加载页面但 js 和 css 不可用。

000-default.conf 文件中的代码

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/public

/etc/apache2/apache2.conf 文件中的代码

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

我的应用程序中的 root 中没有 .httacess,更改后我重新启动了 apache 服务器。 请指导我我所缺少的。

先感谢您。

似乎您需要设置虚拟主机配置。 使用sudo nano /etc/apache2/sites-available/000-default.conf命令(或您使用的任何文本编辑器)打开默认配置文件,并用以下内容替换默认配置

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName example.com
    DocumentRoot /var/www/html/public

    <Directory "/var/www/html/public">
            Options +FollowSymLinks
            ReWriteEngine On
            Require all granted
    </Directory>

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

我对httpd有同样的问题,但我通过添加以下内容来解决它.htaccess

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

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

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

注意在public/目录下添加.htaccess

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM