Saturday, February 19, 2022

[FIXED] How to do a redirect in Laravel for ads.txt

Issue

Google wants have access to ads.txt file like "example.com/ads.txt", but in Laravel we need redirect it to "public" folder.

How do it?

I try RedirectMatch 301 ^ads\.txt$ \/public\/ads\.txt, but it doesn't work.


Solution

You can create blade file has name ads.blade.php and put all text from ads.txt to this blade , and create route like that :

Route::get('/ads.txt',function(){
   return view('ads');
});

I tried that when register my website in google



Answered By - Ahmad Abo Zaid

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.