I have an old site (www.example.com) with approximately 2000 documents (PDF, Word doc, Excel). All the 2000 documents (PDF & Word doc) use these existing links to refer each other.
I have created another site (www.example.net), with a different document path. I want to map the old URLs to the new, so that I don’t lose the visits, and so that a user who has an old file with the old link will still get the documents from the new site.
Old document path: http://www.example.com/sites/docs/abc.pdf
New document path: http://www.example.net/files/resources/def.pdf
(Note that the domain name has changed, the path to the document has changed, and the document name itself has changed. There is no pattern to the change in document names.)
Common Solutions:
-
.htaccessredirects, but there are 2000 docs, so it’s a lot of work -
normal redirects with hard coded URLs in a
.phpfile, which will work the same as the.htaccess
Is there any better solution than these?
If the documents are entirely unique, as in:
abcd.pdfgets redirected topqrs5000_foo.pdf(i.e., there is no correlation at all between the two), then there’s no way around explicitly redirecting all 2000 of them. It’s just a matter of whether you want to put them all in an htaccess/vhost/server config file or in another file and use aRewriteMapand the txt map type. You need to define the map in either the vhost or server config though, it won’t work in an htaccess file, but you can use the map itself in an htaccess file.If the filenames are the same, and only the pathnames are different, you don’t need 2000 redirects at all, simply:
Or alternatively using mod_alias: