关于 Laravel 路由与 public 下的文件或文件夹的优先级问题
1、使用laravel命令行:
php artisan storage:link
为storage建立一个软链接,将上传至stroage/app/public下的图片文件对外暴露,可以使用http://xxx.xx/storage/文件名.jpg来访问。
2、建立控制器
namespace App\Http\Controllers;
class TestController extends Controller
{
public function test3($id)
{
return "TestController@test3=>" . $id;
}
}
3、在web.php中建立路由:
Route::get("/storage/{id}",'TestController@test3');
情况一:
访问时:http://local.api.laravel.com/storage/020.j...
时显示:(020.jpg文件不存在)
TestController@test3=>020.jpg
情况二:
访问时:http://local.api.laravel.com/storage/021.j...
时显示图片(021.jpg是一个确实存在的文件)
nginx配置
Apache配置
是了。我的laravel就配置了.htaccess文件。
多谢回复!学习了。
baidu一下!找到如下资料
.htaccess都可以做什么