Rather unusual plugin request (3 posts)

Topic tags: index.php, PHP, rewrite, wordpress
  • Profile picture of Dave Lee Dave Lee said 1 year, 7 months ago:

    Hi all,

    Before I ask my question, let me give you a bit of background…

    I have a website that utilises Wordpress – http://www.thebugcast.org/
    This website was originally created using a CMS that I built myself but, quite frankly, was a bit poo. However, one of the best features in my opinion was the media redirect service I put in place for the audio files. All of the podcast audio files are hosted on Libsyn, but I wanted the URLs to be published as if they were coming from my website. So I wrote a rewrite that passed all non-existing files and folders to a PHP script that handled the perceived 404. Thus everything that is at /media/ is handled by that script as that folder doesn’t exist.

    When I trashed my old site and replaced it with WordPress, I put all of my processing code in the index.php file, as that was the target for non-existing files within the WordPress installation code.

    The only problem with this, is when WordPress gets updated, it replaces the index.php file, effectively rendering all of my media files as 404s.

    So – and here is the actual question – I’m looking for a plugin that replaces this functionality. So when I request the /media/filename.mp3 URL, it will execute my script using “media” and “filename.mp3″ as parameters.

    Anyone know of such a thing?

    Thanks in advance,
    Dave

  • Profile picture of Michael Kimb Jones Michael Kimb Jones said 1 year, 7 months ago:

    I think, if you move everything into your theme functions.php file you will be OK – will take a little tweaking but that’s how I’d start :)

  • Profile picture of Richard King Richard King said 1 year, 7 months ago:

    If you’re serving Wordpress from Apache I’d investigate using mod_rewrite to change URLs of the form:

    http://www.thebugcast.org/media/filename.mp3

    into the form

    http://www.thebugcast.org/path/to/myscript.php?filename.mp3

    and go from there.