Reputation: 3686
I have set up a simple app for now using ReactJS for the frontend and Laravel(5.1) for the backend.
All is OK but I woudl like to make the URLS look normal, as in the removal of the '/#' from the URL.
So
example.co.uk/#/about
becomes
example.co.uk/about
This is not an issue as I achieve this, but when I do it activate it, then the Laravel routing kicks in and flags a route error.
Is it possible to prevent Laravel form activating / doing this so that ReactJS takes over and works.
If so it would also be nice, so that if a Laravel route is set / wanted then it does use that one.
EG: These are ReactJS routes that would have used the '/#'
example.co.uk/about
example.co.uk/details
example.co.uk/listings
Then if I got to the following URL's then they are controlled by Laravel's routing?
example.co.uk/api/...
example.co.uk/admin/
Thanks
Upvotes: 0
Views: 991
Reputation: 40909
You need a catch-all route that will execute the same main controller action regardless the URL. Add the following to your routes.php
Route::get('{path?}', 'Controller@action')->where('path', '.*');
This way all URLs will go to Controller@action, that should display the base view for your application - the one that runs the ReactJS application.
Upvotes: 4