Forum Moderators: phranque

Message Too Old, No Replies

Invisible rewrite of ads.txt

         

csdude55

4:30 am on Jul 9, 2024 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Doncha just hate it when you haven't done something in awhile, and it feels like you've forgotten even the most basic things? >:-(

I have over 100 sites on my VPS. Most of them use the same info for ads.txt, but that data changes about once a month and it's a HUGE pain to manually update all of the sites!

So I'd like to rewrite example.com/ads.txt to a global ads.txt file. Via Apache .CONF files, of course, so that I could do it once and it would apply to all future sites unless I manually exclude them.

I thought that this would work, allowing me to upload to /home/ads.txt (not web accessible), set the permission to 0777, and all of the sites would use it:

RewriteEngine on
RewriteRule /ads\.txt /home/ads.txt


But alas, no, it's not working. When I go to example.com/ads.txt, it shows the original file instead of the data from /home/ads.txt.

Variations that I tried, but none of them did anything:

# with and without opening /
RewriteRule /ads\.txt /home/ads.txt
RewriteRule ads\.txt /home/ads.txt

# without escaped .
RewriteRule /ads.txt /home/ads.txt
RewriteRule ads.txt /home/ads.txt

# Worst case scenario, I could upload it to example.com
RewriteCond %{HTTP_HOST} !example\.com [NC]
RewriteRule /ads.txt https://www.example.com/ads.txt [R=301,L]

RewriteCond %{HTTP_HOST} !example\.com [NC]
RewriteRule ads.txt https://www.example.com/ads.txt [R=301,L]


Any suggestions on what I'm doing wrong?

I know that I could symlink all of them to the one file, but then I'd have to remember to do it each time I add a new site! So I'd consider that a last resort if I can't get the rewrite to work.