Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Sitemap file and route in laravel

I have a sitemap.xml file in my view folder and this is the route:

Route::get('sitemap.xml',function() {
return response()->view('sitemap')
->header('Content-Type', 'xml');
});

But when i search mydomainname.com/sitemap.xml. It returns InvalidArgumentException View [sitemap] not found.

I tried to search on google and youtube but not able to find any solution.

like image 534
Abdul Wadood Avatar asked Jan 23 '26 05:01

Abdul Wadood


1 Answers

Just move your sitemap.xml to public directory. It doesn't need any Route.

like image 182
Jsonx Avatar answered Jan 24 '26 19:01

Jsonx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!