laravel - Laravel aws 只有第一页有效
问题描述
我将我的 laravel 8 应用程序部署到 aws ec2 实例,但它只是第一页正在工作
.htaccess 文件和 index.php 文件在根目录下
.htaccess 文件
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]
站点可用/laraqueue.conf
<virtualHost *:80>
ServerAdmin support@ahtcloud.com
ServerName http://18.189.174.42
ServerAlias http://18.189.174.42
DocumentRoot /var/www/laraqueue/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/laraqueue/public>
Require all granted
AllowOverride All
Options Indexes Multiviews FollowSymLinks
</Directory>
</virtualHost>
解决方案
跑sudo a2enmod rewrite
像下面的代码一样更新你的conf文件
<Directory /var/www/laraqueue/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
重新启动 apache 服务器。
service apache2 restart