如何从Laravel路由中忽略站点地图网址?

Mit*_*tsa 2 php xml .htaccess routing laravel

sitemap.xmlhttp://example.com的根目录中

当我尝试访问http://example.com/sitemap.xml时。显然会引发路由未找到错误。

因此,尝试将其更改.htaccess为如下所示:

Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/sitemap.xml
RewriteRule ^ index.php [L]
Run Code Online (Sandbox Code Playgroud)

使用的Laravel版本:5.1。

但是,没有运气。我该如何使用和呈现手动生成的XML文件,而不是通过路由进行投放?我不是在这里寻找复杂的XML解析理论。只是尝试从特定路由逃脱。

Sha*_*yal 5

最好的方法是将sitemap.xml文件移动到公共目录。您甚至不必担心路由。

然后它将自动以http://example.com/sitemap.xml进行访问