Ubuntu LAMP on 14.04 legacy redirect dynamic querystring to static file

I have a vanilla droplet Ubuntu LAMP on 14.04 serving up some static documents and html pages at domain. I’d like to redirect one and only one old link to what is now a pdf document on the same domain

I tried adding an htaccess file to www>html directory with the line Redirect 301 /?p=1055 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.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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 ^(.*)$ [R=301,L]

Useful stuff:

Pardon my ignorance. How or Where do I enable these exactly on Ubuntu LAMP on 14.04? Thanks again.