I have an old website that I'm revamping with a custom new Wordpress theme. The old site had a custom (non-WP based) downloads archive that mapped URLs like this:
The ID maps to a download item in a separate MySQL database.
I'd like to move everything over to Wordpress in this refresh and I'm going to be using a custom post type to handle the downloads section, with a custom field that maps the "old ID" to the new post. This isn't difficult and I know how to do this, but the issue becomes remapping the old URLs to the new locations.
The issue I see is that the older URLs are all PHP files (have an extension of
.php). How would I go about create a plugin or Wordpress function in my theme's functions.php file to redirect these old URLs to a new URL. Essentially, I just need to have a Wordpress function redirect from
/downloads/2/, or another more optimized URL (
How would I go about handling pages with a URL of "
/downloads/view.php" and "
/downloads/download.php" and performing the redirect?
I know I can use the
.htaccess file, but I'd prefer to do this directly in a Wordpress plugin if possible for portability...