I want to create a sitemap for laravel,
structure same like wordpress’s rankmath sitemap…
i am adding a route like this
- **Try 1**
Route::get("/(*).xml", "SomeController@serve");
- **Try 2**
Route::get('{slug}.xml', 'SomeController@serve');
But it’s not working…
Can anyone provide better solution?
Rankmath sitemap
2
Answers
Here’s an example of how you can create a sitemap route with a parameter in Laravel:
SomeController.php
Reference URL: https://chriswray.dev/posts/how-to-create-a-sitemap-in-laravel-for-a-website-that-contains-thousands-of-records
I propose a different approach
public/
so that every time you don’t have to create them on the fly.robots.txt
fileLibrary for creating sitemap sitemap