Ignore Case with apache - apache

I have a website where I was forced to move over a bunch of pdf files from a windows server and many of the files have capitalization. This of course shows a file not found if someone has a link going to the file without the correct case. Its a big problem since my client has a many links pointing to these files with a myriad of case options.
I have enabled the speling module in apache and it seems to have helped with ignoring case for urls but NOT FOR THE PDFs.
Does anyone have a work around for this?
I followed these instructions for enabling the speling module: http://keystoneit.wordpress.com/2007/02/19/making-apache-case-insensitive/

As it's a file system feature under *nix boxes rather than apache specifically, you can batch rename all your pdf files to small case using shell or using some server-side scripting language and can
redirect all non-matching pdf requests to a guidelines page using htaccess where you can inform the user to type small case letters for the pdf file and also
you can give him download link with lowercase letters for the filename extracted from the url..

Related

Change matadata of pdf exported from Google Drive on the fly

I have a url in my website that opens a pdf page that is loaded from Google Drive using https://docs.google.com/document/d/[document id]/export?format=pdf url, using a simple php readfile code. However, the generated pdf does not have metadata such as Title, Author, and Description.
What is the best way serve the pdf with the updated metadata?
Caveats:
The website uses a shared cPanel web hosting.
I cannot install perl modules.
The host doesn't provide native php pdf support, and I don't have access to composer.
The only supported server-side languages are perl and php.
The only acceptable solution I found was using ConvertApi, which has a very limited free account (1500 seconds). However, I can get around that by caching the pdf and either retrieving a new copy when it's been over a day since the it was last updated or when I pass an argument to force it to re-cache.
Do you recommend any other solutions? I very much rather have set-it-and-forget-it solution.
Or is 1500 seconds enough for a file that is rarely going to be used?

Show content of a zip file in a browser, rather than downloading it

I have a log server, where users upload archives and view their content online when needed. Currently the server unzips files, right after receiving them. Unfortunately, my peers consumed all the drive space I had. I can free up a lot of space, if there's a way of storing ZIP archives, but feeding them to users as HTML page (same as default Apache's file browser).
I know there are solutions relying on JS, like:
http://gildas-lormeau.github.io/zip.js/demos/demo2.html
https://stuk.github.io/jszip/
or I can unzip them on demand at server side and provide link to a temporary folder. However, some time ago I've heard a browser can view an archive content if proper headers are sent from Apache/nginx. Apache's mod-deflate doesn't help much here and I can't find other docs - perhaps it's not possible after all?
Cheers.

Preventing direct access to files in IIS 7

I have a PHP application running on a Micrisoft IIS 7 server. The application shows PDF files on an iFrame, which contains user's sensitive data that I wouldn't like to be directly accessed by anyone that knows the file address.
So basically, I'm looking for a way to protect files from direct browser access or download, but still be able to show it on the application's iFrame.
I made some research with Rewrite rules, but since the "HTTP_REFERER" of an iFrame is empty, I couldn't find a good solution
Any suggestions for this?
Thanks in advance
Without seeing any of your code, or how your application works, I can only give suggestions based on how I think your app works.
Rather than showing the files themselves, with links directly to those files, you should consider changing your application so that the PHP reads in the directory, displays the file names (however you want them to appear), with links that go to a download.php page. The download page (after checking whether the user has permission to download the file) then loads the file into memory and serves it out as a response (with appropriate Content-Disposition and Content-Type headers).
Since your PHP application can read files directly within the web directory, you can set up rewrite rules to prevent accessing those files from the web; that way, the files can only be accessed by the PHP application, which doesn't rely on rewrite rules to access the drive.
This is how places like Source Forge can display an advertisement with a countdown that your file download will begin in 5 seconds.

OS X Lion - Website sharing , display directory files

I need some help to get Mac WebSite sharing to work as i want.
Basically i need to know how i can make it display the files of a directory.
Do i need to make a website to show my directory files or is there any other way ?
And if i do need to make a website to display my directory, what code should i use to do so ?
I am no expert on HTML at all.
Allso, i have been searching around for this and i couldn't find any answers related to my question.
You need to turn indexes on in your Apache config. This could be on by default. Check to see if you have folder named Sites in your home directory. If you do rename the index.html page (if there is one) and then navigate to http://localhost/~yourusernamehere.
The same applies if you are using the default apache directory (the system wide one) which is located in /Library/WebServer/Documents if I remember correctly. In this case you would navigate to http://localhost. I just checked on my system (OS X 10.7) and the indexes were enabled by default.
You will need to use a server-side language such as PHP, Java, ASP.NET if you want to display the 'servers' directory on a web page. I will say because you're a begineer use PHP as it's very easy to learn...
Download MAMP / XAMPP.
Research PHP and follow some tutorials first, and then implement directory searching and output it as HTML.
http://php.net/manual/en/ref.dir.php
Code:
http://css-tricks.com/snippets/php/display-styled-directory-contents/

Malware Appearing in JS Files

Something is automatically editing our site's global JS files to include malware. It's CHMODing the files, one at a time, to 777 and then appending the code. It started with one file but now has moved up to two. The site is on an apache server running PHP/mySQL/JQuery
This has been a nightmare, does this behavior hint at any specific type of exploit (FTP? JS? SQL?) The malware leads to the "Black Hole Exploit"
Just read in popular blogs, that some other people got the same problem. Seemed, that was fckeditor's file aupload vulnerability.