[英]Laravel 5.6 '/' route found but other routes not found AWS EC2
I am new to laravel and AWS.我是 laravel 和 AWS 的新手。 I am trying to run my application on AWS EC2 apache server.我正在尝试在 AWS EC2 apache 服务器上运行我的应用程序。 My application is working fine in local system but once I tried to upload code on AWS only index route (ie '/') is working fine.我的应用程序在本地系统中运行良好,但是一旦我尝试在 AWS 上上传代码,只有索引路由(即“/”)运行良好。 For other routes, it is giving me NOT FOUND error.对于其他路线,它给了我NOT FOUND错误。 If I try to run application /index.php/login it is loading a page but js and css are not available.如果我尝试运行应用程序 /index.php/login 它正在加载页面但 js 和 css 不可用。
Code in 000-default.conf file 000-default.conf 文件中的代码
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/public
Code in /etc/apache2/apache2.conf file /etc/apache2/apache2.conf 文件中的代码
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
There is no .httacess in root in my application and I restarted apache server after changes.我的应用程序中的 root 中没有 .httacess,更改后我重新启动了 apache 服务器。 Please guide me what I am missing.请指导我我所缺少的。
Thank You in advance.先感谢您。
It seems you need to setup your virtualhost configurations. 似乎您需要设置虚拟主机配置。 Open your default configuration file with sudo nano /etc/apache2/sites-available/000-default.conf
command (or whatever text editor you use) And replace default configurations with belows 使用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>
I've same issue with httpd but I resolve it by adding following with .htaccess
.我对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>
Note that to add .htaccess
in the public/ directory.注意在public/目录下添加.htaccess
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.