3

I am trying to create a catchall url that starts with the prefix "angular". How do I do this?

I tried the following but does not work:

Route::group(['prefix' => 'angular'], function () {
    Route::get( '{catchall}', function () {
        return "YES!"
    } )->where('catchall', '(.*)');
});
Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
Yahya Uddin
  • 26,997
  • 35
  • 140
  • 231

1 Answers1

6

The following should work:

Route::group(['prefix' => 'angular'], function () {
    Route::get( '/{catchall?}', function () {
        return "YES!"
    } )->where('catchall', '.*');
});

Be aware that you should put such route as last route because in case you have any specific route for example angular/dosomething it would also go to this catch all rule in case it would be after this catch all rule.

Yahya Uddin
  • 26,997
  • 35
  • 140
  • 231
Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
  • This unfortunately did not work for the url "/angular" – Yahya Uddin Jun 26 '16 at 14:15
  • @YahyaUddin Try `'/{catchall?}'`. – ceejayoz Jun 26 '16 at 14:31
  • Yes thats the answer, which I also already posted. I submitted an edit on your answer, so once it goes through I'll delete my answer and mark yours as the correct one as it did help. – Yahya Uddin Jun 26 '16 at 14:36
  • 1
    @Yahya it is good that you deleted your answer. Marcin clearly solved the problem so a little more than "it did help" in terms of credit was due. It's the principle. Anyway you've done the right thing now so all's fine. – Jonathan Jun 26 '16 at 14:41