Sanjeev Sabhlok's notes on technology, hardware, gardening

How to change URLs linking public documents, to Onedrive, on WordPress. Redirect through .htaccess.

I've been publishing a lot of "work in progress" documents on sanjeev.sabhlokcity.com/Misc over the past few years. To make these easy to edit and to use the "auto-upload" feature provided by Onedrive, I've got to not only update the URL of these files across the entire WordPress system, but also ensure that anyone who stumbles to the old link is also able to reach the new link.

Step 1: Upload the file into the "Public" folder of Onedrive (this has default public settings).

Step 2: Find the URL of the Onedrive file by right click on the file > share > create link (choose public) > in the URL replace "redir" by "download".

Step 3. Create a bit.ly URL since the Onedrive URL is extremely long.

Step 4. Replace the link on the relevant Wordpres widget with the bitly link, e.g. http://1drv.ms/1jMLtCi

Step 5: Go to the phpmyadmin, selecte the relevatn database and use the following as example to replace all outdated references (run the SQL) with the new link

UPDATE wp_posts SET post_content = REPLACE (  

post_content,  

'http://sanjeev.sabhlokcity.com/Misc/The-truth-about-Modi.doc',  

'http://1drv.ms/1jMLtCi');  

Step 6: In the root directory, add the following line into the .htaccess file (just above the "turn off the server signature on bulletproof htaccess, or close to the top on any non-bulletproof htaccess, I presume)

redirect http://sanjeev.sabhlokcity.com/Misc/The-truth-about-Modi.doc http://1drv.ms/1jMLtCi

MY HTACCESS CHANGES FOR THE RECORD

redirect http://sanjeev.sabhlokcity.com/Misc/The-truth-about-Modi.doc http://1drv.ms/1jMLtCi
redirect http://sanjeev.sabhlokcity.com/Misc/Notes-on-innovation.doc http://1drv.ms/1nBRZPx
redirect http://sanjeev.sabhlokcity.com/Misc/Modi-s-lies-to-the-SIT.doc http://1drv.ms/SrOWMI
redirect http://sanjeev.sabhlokcity.com/Misc/Free-Speech-Manifesto.doc http://1drv.ms/1gq9ujx
redirect http://sanjeev.sabhlokcity.com/book3/hc.doc http://1drv.ms/1hikHxJ
redirect http://sanjeev.sabhlokcity.com/Misc/Scientific-Hinduism-meat-beef-India.doc http://1drv.ms/1lJoiG5
redirect http://sanjeev.sabhlokcity.com/Misc/Scientiific-hinduism-2-institutionalised-oppression.doc http://bit.ly/1jMJpMf
redirect http://sanjeev.sabhlokcity.com/Misc/The-Robotic-Age.doc http://1drv.ms/1hiCUes
redirect http://sanjeev.sabhlokcity.com/Misc/Notes-on-IQ.doc http://1drv.ms/1p2s5Vl
redirect http://sanjeev.sabhlokcity.com/Misc/Arvind-Kejriwal-is-a-socialist.doc http://1drv.ms/1vV3BiH
redirect http://sanjeev.sabhlokcity.com/Misc/The-net-benefit-of-CO2.doc http://1drv.ms/RleSIG
redirect http://sanjeev.sabhlokcity.com/Misc/Cost-benefit-analysis.doc http://1drv.ms/1pllKSh

Print Friendly

sabhlok

View more posts from this author

Leave a Reply

Your email address will not be published. Required fields are marked *