Knowledgebase: How To
Naming convention causes 500 Internal Server Errors
Posted by Brandon Elliott on 06 March 2016 06:08 PM

Over the years, we have seen that some users want to save their website screenshots with a simple and obvious naming convention like: domain.tld.jpg

For instance:

cnn.com.jpg

bing.com.jpg

In these cases, however, the web server (Apache in our testing) may try to run images as executables when they match certain extensions. For instance, since Polish TLDs (.pl) would be saved as domain.pl.jpg, many installations of Apache would see this as a Perl file and attempt to process it as such, resulting in a 500 Internal Server Error.

One of our users suggested some code to handle Polish domains:

if(ereg("\.pl$", $url)) {
  $url = str_replace('.pl','.pol',$url);
}

However, there may be others that would need to be handled as well. So, we are providing a small .htaccess modification to prevent all of these types of issues:

<Directory "/path/to/your/thumbnail/directory">
  Options -ExecCGI -MultiViews
  AllowOverride All
</Directory>

This should prevent any issues, provided that you do not keep executable files in the website thumbnail directory.

As a final note, it is not recommended to use a naming convention like this if you ever plan on supporting full URLs, such as domain.tld/path/to/page.html. Therefore, you will find that all of our sample code builds a hash specific to the domain, size, and other parameters.

(0 vote(s))
Helpful
Not helpful

Contact Us | PagePix Benefits | Learn More | STW Forums | Our Partners | Privacy Policy | Terms of Use

©2016 ShrinkTheWeb. All rights reserved. ShrinkTheWeb is a registered trademark of ShrinkTheWeb.