Need .htaccess help...

rstark's picture

I was wondering if there are any .htaccess gurus among us? I have very limited exposure and I am having a hard time figuring this one out.

This is with regard to the Department of Correction website (www.idoc.idaho.gov) We are using URL aliases which work great, however - when you open, let's say a pdf file, the full path to the folder that file is located in is now displayed in the address bar. What we'd like to do is have the alias displayed instead. Does anyone know how to do this? I have been scouring the 'net for examples but haven't been successful in finding exactly what we need and I don't really understand the .htaccess tags well enough to piece it together myself.

Suggestions?

Thanks,
Rhonda

Comments

whthat's picture

Maybe think about a PDF viewer you can integrate into your nodes, something like Scribd which has some great PDF features. Also here is a scribd input filter for easy display on nodes, http://drupal.org/project/scribd_filter

Here is link that may help with the .htaccess this will redirect "site.com/pdf/yada.pdf" to a longer site.com/sites/files/directory/pdf/yad.pdf" it also includes some logging options to help identify any rewrite issues. http://dominiquedecooman.com/blog/drupal-alias-your-file-paths-using-htaccess

Thanks for the response...

rstark's picture

The redirect from "site.com/pdf/yada.pdf" to a longer site.com/sites/files/directory/pdf/yad.pdf" is what it's currently doing but I want it to display the "site.com/pdf/yada.pdf" in the address bar and that's the step I haven't been able to figure out. Thanks for the links though - I will check out the logging stuff - that may help us see what's happening.

jeremy.zerr's picture

Just have the site.com/pdf/yada.pdf as a menu path in Drupal, then have the function handler for that path just return the contents of the file site.com/sites/files/directory/pdf/yad.pdf. That way, the path still shows in the address bar and the appropriate file will be returned. That's what I would do anyways, very simple code, very fast to implement, and doesn't require more than a few lines of code.

I do something just like this for an application I have where I am tracking impressions for an image on another web site, but users go through my site. I have an internal URL called first that logs the impression, then I return the desired image to the user via php, the user doesn't see that the image comes from another site.

Jeremy Zerr
http://www.zerrtech.com

Thank you...

rstark's picture

Thanks, Jeremy - we were able to get it to work using your suggestions!

Rhonda

I think there is a module for that!

whthat's picture

Take a look at http://drupal.org/project/file_aliases. "The File Aliases module allows you to use token customizable aliases for your uploaded files"

Nice

rstark's picture

Thanks for the info - I will keep it in mind. Fortunately, problem is solved using Jeremy's suggestions. I appreciate the help!!

Rhonda

You should really consider

cweagans's picture

You should really consider using file_aliases. The solution that Jeremy suggested may work, but why would you want to maintain a bunch of custom code if you could use a contrib module instead?

--
Cameron Eagans
http://cweagans.net