laravel The requested URL was not found on this server
输入index.php是无异常的,但是进入自己定义的route时,如果地址栏中不包含index.php就( 注意是apache 服务器时)
需要排查两个地方:
1.apache 的rewrite_module 是否已经打开 LoadModule rewrite_module modules/mod_rewrite.so
2.public目录下是否有.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>
再次请求异常解决。
————————————————
我自己的.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>
posted on 2023-05-15 10:31 andydaopeng 阅读(325) 评论(0) 编辑 收藏 举报