Tag Archives: .htaccess

WordPress Media upload HTTP Error

WordPress and WordPress-MU have given me the HTTP error in the various installations I have performed and each time there’s a different cause. This post is nothing more than a personal notation for future reference but I hope it’s helpful to someone.

Error: when trying to upload media using the WordPress Flash uploader it get the message HTTP Error

Disclaimer: before messing with your .htaccess file, make sure you have a backup copy of it in case it causes a 500 Server configuration error. If this happens just replace the .htaccess file with the back up version. Check your code for any mistakes and try again.

Possible causes:

  • mod_security – basically all Apache servers will have it turned on, so you may need to turn it off for the async-upload.php file using .htaccess. The newer versions of WP have added this code already, but in case you mess up your htaccess file, here it is.  Just add the following lines to the bottom of your .htaccess file in the root folder of your WP or WP-MU installation. 
<IfModule mod_security.c>
<Files async-upload.php>
SecFilterEngine Off
SecFilterScanPOST Off
</Files>
</IfModule>

  • Access Denied Error 403/ Permission issue – another typical problem. Make sure that the upload folder is writeable by the server, you can set the permission to 754 and it should work fine. In WordPress the upload folder sits under /wp-content/  in WP-MU it sits under /blogs.dir/”blog number”/files  (default site blog number is 1 and the other blogs are numbered in ascending order of creation)
  • PHP Upload limit – check you PHP.ini settings for the settings upload_max_filesize and post_max_size. You can change these directly in your PHP.ini if you have access to it or you can change it by adding a php.ini file to you root directory with the following code. The default is normally 2M but you can change it to anything at your own risk, you should not need more then 8M.)
post_max_size = 8M
upload_max_filesize = 8M

or by adding the following lines to your .htaccess file:
php_value upload_max_filesize 8M
php_value post_max_size 8M

for anything above 8M you may need to add an execution time to the .htaccess code also
php_value max_execution_time 800

  • Authentication Failed Error 401- I checked my server log and noticed that WordPress was trying to access the 401.shtml error template every time I got the HTTP error during a media upload attempt. This normally occours if you are using password protection for the WordPress root folder or the folder where your uploads should reside. You should disable the password protection on the folder i norder for the uploader to work.

Hope it helps. Please leave your contributions and bug reports so others can benefit from it.

Technorati Tags: , , , , , ,

.htaccess 301 Redirect

.htaccess files (or “distributed configuration files”) provide a way to make configuration changes on a per-directory basis in an Apache HTTP Server. This file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all subdirectories thereof.

This 301  Redirect can be used anytime you want to redirect a URL. Here are some examples of its use:

  • Single page – Redirect 301 /old_page.html http://www.mysite.com/new_page.html
  • entire site -   Redirect 301 /  http://www.new_site.com/
  • change file extension (html to php in this case) -  RedirectMatch 301 (.*)\.html$ http://www.mysite.com$1.php

There are many other uses for Redirect 301 and mod_rewrite on Apache, if you are moving a site or redesigning a site with a new CMS make sure you redirect your old URLs to your new site. By failing to do so any user that clicks on a link to your old site (page) will hit a 404 ERROR page, this will affect your search rankings. 

The book “Professional SEO” has a good chapter in mod_rewrite and URL redirection, and is also great SEO manual

For a full tutorial on .htaccess visit the official Apache website.

Technorati Tags: , , , , , ,