Search code examples
.htaccesslaravel-5adsense

How to do a redirect in Laravel for ads.txt


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