.htaccess is a file that controls the configuration of Apache in a specific directory and tells it how to interact with WordPress or other applications on the server.

WordPress depends on Apache URL rewriting engine to handle easy to read URLs (permalinks). When setting up WordPress + Scriblio, one of the first things you’ll want to do is get permalinks running, and the best way to do that is to create a .htaccess file in the base of your WordPress installation with these contents:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

Alternatively you can “touch .htaccess” in that location, then “chmod 777 .htaccess” (or otherwise make it writable by the same user that Apache runs as), and then update your permalink structure again. WP will put the proper contents in there for you.

No matter what you do, you’ll need to go back to the permalink options and click the update button so that WP can reset itself from the /index.php?p=1234 funny business.

PHP Configuration

.htaccess files can also be used to set or alter the PHP configuration. One common use is to increase the maximum size for uploaded files (like MARC records). The following example includes a few common setting changes:

php_value display_errors yes
php_value magic_quotes_gpc 0
php_value memory_limit 256M
php_value upload_max_filesize 20M
php_value post_max_size 20M
  • Many servers are setup to hide PHP errors. That improves security but makes installation and debugging more difficult. Turn display_errors on when you need it, and off when you don’t.
  • magic_quotes_gpc should always be off, and most servers are configured that way.
  • memory_limit sets the maximum amount of RAM PHP can use while processing a single request.
  • upload_max_filesize and post_max_size limit the maximum size of an uploaded file.

2 Responses to “.htaccess”

Leave a Reply

Comments should show a courteous regard for the presence of other voices in the discussion. We reserve the right to edit or delete comments that do not adhere to this standard.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>