By metaprinter
I have a vanilla droplet Ubuntu LAMP on 14.04 serving up some static documents and html pages at mysite.com domain. I’d like to redirect one and only one old link mysite.com/?p=1055 to what is now a pdf document on the same domain mysite.com/resources/1055.pdf
I tried adding an htaccess file to www>html directory with the line Redirect 301 /?p=1055 http://mysite.com/resources/1055.pdf but that didn’t work at all.
I should note that the old URL was from when the site was a wordpress site, but it isn’t any longer. The current domain doesn’t use querystrings.
If someone could point me in the right direction and please explain what I need to do…perhaps like i’m a child or a dog ;) It would be greatly appreciated.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess file:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^p=([0-9]*)$
RewriteRule ^(.*)$ http://mysite.com/resources/%1.pdf? [R=301,L]
Useful stuff: http://httpd.apache.org/docs/trunk/rewrite/remapping.html http://iswwwup.com/t/47986b2d8d38/php-htaccess-query-string-redirect.html
Pardon my ignorance. How or Where do I enable these exactly on Ubuntu LAMP on 14.04? Thanks again.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.