To achieve this, you can create two separate sitemap files for each domain and place them in the public folder of your Laravel project. Then, you can create two routes in your web.php file to serve the sitemap files for each domain. Here's an example:
- Create two sitemap files in the public folder:
public/sitemap-xyz.xml
public/sitemap-abc.xml
- Create two routes in your
web.phpfile:
Route::get('sitemap.xml', function () {
return response()->file(public_path('sitemap-xyz.xml'));
})->name('sitemap.xyz');
Route::domain('abc.com')->get('sitemap.xml', function () {
return response()->file(public_path('sitemap-abc.xml'));
})->name('sitemap.abc');
- In your
robots.txtfile, add the following lines to point to the sitemap files:
Sitemap: https://xyz.com/sitemap.xml
Sitemap: https://abc.com/sitemap.xml
With these changes, you should be able to access the sitemap files for each domain at the following URLs:
https://xyz.com/sitemap.xml
https://abc.com/sitemap.xml