[英]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.