简体   繁体   English

Laravel 后端中未显示前端路由

[英]Frontend Routes not showing in Laravel backend

I am having issues with routing in my projects.我在我的项目中遇到路由问题。 In my project I have a laravel backend and an angular frontend.在我的项目中,我有一个 laravel 后端和一个 angular 前端。 My laravel backend has a route wildcard in my web.php that allows my angular app to control routing.我的 laravel 后端在我的 web.php 中有一个路由通配符,它允许我的 ZD18B8624A85F5F762DDZ 应用程序控制路由。 Here is my web.php file这是我的 web.php 文件

<?php


    Route::domain('localhost')->group(function(){
        Route::view('/{path?}/', 'index');
    });

Now if I visit a route such as localhost:8000/login it works fine but when i visit a page such as localhost:8000/admin/login I get a 404 laravel not found error.现在,如果我访问诸如 localhost:8000/login 之类的路由,它可以正常工作,但是当我访问诸如 localhost:8000/admin/login 之类的页面时,我会收到 404 laravel not found 错误。 What do i need to do?我需要做什么?

If you want to actually catch all, you need to use a regex pattern.如果您想真正捕获所有内容,则需要使用正则表达式模式。 Laravel's routing takes into account the segments / in the URL. Laravel 的路由考虑了 URL 中的段/ You need to tell it to accept anything:你需要告诉它接受任何东西:

Route::view('{all}', 'index')->where('all', '.*');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM