404 Not Found Route Laravel 5 Sitemap Dynamic

33 views Asked by At

im new in laravel and i'm trying to make dynamic sitemap using Laravel Version 5.5, but when im trying with i still got "404 Not Found", but when im trying on new laravel 10 it's works perfectly, when im trying with only "/sitemap" without .xml it's work, but when im trying with extension like ".xml" or ".html" can't work because file not found.

Here's my web.php "This is only for tester"

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
//User Login

use Illuminate\Support\Facades\Route;

// Route::get('/sitemap.xml', 'SitemapController@sitemap')->name('sitemap'); // ERROR "NOT FOUND"
Route::get('/sitemap', 'SitemapController@sitemap')->name('sitemap'); // WORKS

Route::get('testing.html', function(){ // ERROR "NOT FOUND"
    return 'hello from testing.html';
});

and Here's my SitemapController.php "This is only for tester"

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class SitemapController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function sitemap()
    {
        return response()->view('sitemap')->header('Content-Type', 'text/xml');
    }
}

and Here's my sitemap.blade.php "This is only for tester"

<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc>https://localhost:8000/</loc>
        <lastmod></lastmod>
        <changefreq>daily</changefreq>
        <priority>1.00</priority>
    </url>
</urlset>

This is screenshot file not found on localhost using Xampp and Using Route "/sitemap.xml":

enter image description here

This is screenshot file not found on localhost using Xampp and Using Route "/sitemap" without ".xml":

enter image description here

0

There are 0 answers