Invalid command ‘Header’, perhaps misspelled or defined by a module not included in the server configuration

So I had an old script that created the .htaccess file for a folder that I wanted to force all files to download instead of rendering, or processing however they normally would. The script for that file can be done in any language, but the .htaccess contents are as follows ForceType application/octet-stream Header set Content-Disposition attachment It’s pretty self explanatory. Notice the Files *.* part. That means any file. You can...

Read More

Redirect your whole domain to a new domain with a 301 redirect through the .htaccess file

The great thing about SEO is that it’s all tied to your domain name and not an IP address of the server where your files are being stored. However, being tied to a domain name hurts you in some situations as well. Consider if someone started a website on a free site, like WordPress.com and built up a fairly large following and some good SEO power. Now their domain is something like myblog.wordpress.com. This isn’t great from a...

Read More

Apache Password protecting a Directory

Password protecting a directory in Apache means that a username/password prompt will appear if someone trys to access any of the files in that directory, or that directory itself. They don’t have to do it every time they load a new page, if you for instance have an application in the directory, as it creates a session and saves the fact they authenticated themselves. To set this up, add the following into your apache site. Most likely it...

Read More

Apache Redirect to Secure Link

If you have a directory that you want to force users into an SSL connection, the easiest way is to use a .htaccess file if your host allows it. The following will force any page to redirect to https:// if they aren’t on it already. RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} If you want to exclude a directory or filename specifically, then just add in another rewrite condition as shown...

Read More

Forcing the Download Prompt for files

Sometimes you want to force a file to be downloaded instead of letting the browser decide how to handle it. For alot of servers, text files, for instance, will be displayed on the screen as a bland text page with no formatting. Instead you may want the download prompt to come up, have the user download the file, then have them continue on their way on your website. To accomplish this simply add an .htaccess file to the directory that the file...

Read More