Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore sitemap url from Laravel routing?

I have sitemap.xml in the root directory of http://example.com

When I try to access http://example.com/sitemap.xml. It obviously throws route not found error.

So to try this changed .htaccess to look like:

Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/sitemap.xml
RewriteRule ^ index.php [L]

Laravel version in use: 5.1.

But, no luck. How can I just make use and render manually generated XML file rather than serving from route? I am not looking for complex XML parsing theory here. Just trying a hook to escape from the specific routing.

like image 420
Mithun Shreevatsa Avatar asked Dec 17 '25 21:12

Mithun Shreevatsa


1 Answers

The best approach is to move the sitemap.xml file to the public directory. You do not even have to worry about the routing as well.

Then it will automatically be accessible as http://example.com/sitemap.xml

like image 158
Shakti Phartiyal Avatar answered Dec 20 '25 12:12

Shakti Phartiyal