Forward MP3 Requests to a Webpage?

Hi all,

I’m retiring a personal music website that serves ~6,000 MP3 downloads per month. Rather than abandon those listeners, I’d like requests for MP3s (e.g., http://mysite.com/downloads/song.mp3) to deliver a webpage - “this site is moving” - instead of delivering the requested audio files. My first thought is a URL rewrite but then I’ve never forwarded one MIME type to another. Can this be done? Any downsides? Other ideas?

Any advice is greatly appreciated.

1 Like

Hi david_d welcome to the forum

Getting the htaccess file right without breaking the site can be tricky, so save a backup, think about the changes carefully, and be prepared to restore the backup quickly if need be.

I have done similar with success

RewriteRule {path}/{regex}/\.js  {path}/file.php 

-BUT- “file.php” created dynamic JavaScript and output ContentType application/javascript HTTP headers.

I don’t know what would happen if the ContentType didn’t match what was expected.

I think the safest would be to redirect all requests to a “moving.mp3” file
I’m thinking it might be OK to redirect to an image file or maybe even a plain text file, but I think a lot would depend on how the files are accessed. A browser, probably OK. FTP or app, maybe not so much.

Yeah, I was afraid of that. I just can’t imagine too many listeners will appreciate an unprompted “go here” audio file. We’ll see how many ‘click throughs’ we get. :smile:

Is what it is.

Thank you for your help!

d_d/Alan,

mod_rewrite can redirect anything. Remember all the members who want to protect image files that redirect to a “don’t pirate my images” webpage? It would be an easy matter to redirect ALL mp3 requests to a handler page (like a 404 but send on to the new website).

RewriteEngine on RewriteRule ([a-zA-Z]+)\.mp3$ /redirection.php?requested=$1.mp3 [L]

and set a meta location with a 10 second timer (long enough to read about the move) whose location is the new website’s mp3 file (it’s in the query string as the value of the requested key) or the mp3 file list or player or … with code in the section like:

<meta http-equiv="http://NEWdomain/path/to/<?php $_GET['requested']; ?>" content="10"> <!— redirects after ten seconds to the requested mp3 file at the new domain's website —>

Regards,

DK

1 Like

Thank you, DK!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.