WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wan to change my premalinks to attachment pages from http://example.com/.../attachemnt/something to http://example.com/.../attachemnt/something/something.jpg

It should simply add filename but with nice url, I tried with add query arg() but this builds url query like ?name=something.jpg.

Is there solution to achieve this without hard coding anything to wordpress?

share|improve this question
Why would you want to do that? Would it not be easier to reference the actual file? eg. wp-content/uploads/2010/12/yourfile.jpg if you want the file name and extension in the URL.. – t31os Dec 20 '10 at 10:40
While the question is technically interesting, won't displaying image-like URL for HTML page be confusing? – Rarst Jan 17 '11 at 8:19

This doesn't require a Wordpress modification per se, but if you prefer to do it that way, here is a decent tutorial: http://shibashake.com/wordpress-theme/wordpress-page-redirect. Some people would, however, prefer to do this via the .htaccess file, here is a quick guide on how to do redirects that way: http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/#red1.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.