Alden Bates (abates) wrote,
Alden Bates
abates

.htaccess Rewrite Engine gotcha

I've been wondering why my 403 (access denied) scripts for my music and NZDWFC subdomains on my site weren't working. They log all hits from sites attempting to hotlink to my graphics - a while back I inserted some mod_rewrite voodoo into the .htacces file on tetrap.com to prevent all hotlinking, including on the domains.

I decided to try an experiment - I banned my own IP and tried to access the NZDWFC site. I got a 403 error, and the 403 script logged the error properly, so the scripts were OK.

I then tested the hotlinking by translating a page in Google. The graphics loaded. The image hotlinking protection on the two subdomains was broken. Buggery.

It turned out to be because I'd added mod_rewrite blocks to the .htaccess files for the subdomains, in order to redirect www.music.tetrap.com to the shorter music.tetrap.com. Apparently these rewrite blocks overrode the one in the .htaccess file for the domain as a whole, and that's where the voodoo for banning hotlinks was located. Fixing it was a matter of copying the appropriate hotlink prevention lines into the .htaccess files on both subdomains.

I now anticipate a flood of failed hotlink attempts, as no doubt people have been linking to album covers like mad.
Subscribe

  • ST:V: Learning Curve

    Learning Curve: Tuvok tries to train some ornery Maquis crew members. Janeway is in her Mary Poppins holosim, interacting with her holocharacters…

  • ST:V: Jetrel

    Jetrel: A Haakonian scientist who developed a WMD pays a visit to Voyager. Neelix plays Tuvok at pool. Neither of them appears to be all that good.…

  • ST:V: Faces

    Faces: A Vidiian scientist splits Torres into her human and Klingon halves. The "genatron", eh? Sounds mildly dodgy. That pre-credits teaser is...…

  • Post a new comment

    Error

    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments