Skip to content

Commit

Permalink
Separate api and admin robots.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
armin-salihovic committed Jun 23, 2024
1 parent 12895cb commit 349e7d1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
File renamed without changes.
2 changes: 2 additions & 0 deletions public/robots-api.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Disallow:
17 changes: 16 additions & 1 deletion routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@
|
*/

Route::get('robots.txt', function () {
$subdomain = \Illuminate\Support\Arr::first(explode('.', request()->getHost()));

$robotsFile = public_path('robots-api.txt');

if ($subdomain === 'admin') {
$robotsFile = public_path('robots-admin.txt');
}

return response(
file_get_contents(
$robotsFile
), 200)
->header('Content-Type', 'text/plain');
});

Route::domain(config('app.url'))->group(function () {
Route::get('cache', function() {
$cache = Cache::first();
Expand All @@ -29,5 +45,4 @@
Route::post('send-email', [MailController::class, 'sendEmail']);
Route::get('settings', [PageController::class, 'getSettings']);
Route::get('{slug}', [PageController::class, 'show']);

});

0 comments on commit 349e7d1

Please sign in to comment.