.htaccess and WordPress
Everyone at some time or another has had an issue with .htaccess and their WordPress installation. This typically has implications for the use of Permalinks, but it impacts other things as well.
This post is an attempt to make some things clear for users.
What are permalinks?
Permalinks are the URL’s created for each individual post. Typically, an application like WordPress creates that link this way: http://www.yoursite.com/?p=54 or something to that affect. It is not very pretty nor search engine friendly. Changing the permalink structure can create both pretty and search engine friendly links. For example: http://www.yoursite.com/mycategory/this-is-what-i-think
For more info see Using Permalinks on the WordPress Codex site.
Before employing pretty permalinks there are several questions to ask.
What version of Apache is the web host using? Apache is the web server used by many web host providers to “get” your web site onto the Internet. Typically this could be found in the administrative panel provided by your web host. A lot of providers use cPanel as the administrative tool. On mine, there is an Info Button. The Info page has a Versions and Paths link. Clicking that link displays the various services used by my web host and the version of each service. In my case, Apache’s version is 1.3.33. The navigation to this information may be different then what I described. If you need help, leave a comment or email me.
If Apache is anything less than version 2.0 OR you host does not use Apache, then you only have one choice for permalinks.: /index.php/ needs to be included as part of the permalink structure.
Example:
www.yoursite.com/index.php/this-is-what-i-think.
See the Options/Permalinks menu within Wordpress for more info on setting this up. Though this method is considered a “hack”, it avoids having to deal with the .htaccess file.
If Apache is 2.0 or above, then you must determine whether the host has an Apache module called mod_rewrite installed on your server.
How do I find out if mod_rewrite is on my server?
Sometimes the administrative panel will have a button to access PHP info. If not, temporarily create a page named “test.php”. Add one line to this file:
php_info();
Upload the file to your website. Access the file through your browser: http://www.yoursite.com/test.php
The screen should display a white background with purple headings detailing the PHP installation. Look for the category labeled Apache. Under this category there should be a row labeled “Loaded Modules”. In the cell next to this label look to see if the mod_rewrite is listed. If it is, then it is installed.
If you have Apache 2.0 or higher and mod_rewrite is installed then you can use the method described below for the permalink structure, else you will have to use the solution above that uses /index.php/.
This method updated the .htaccess file. Starting with WordPress 1.5, WordPress automaticaly updates this file.
I have included two helpful posts from the WordPress support site that simplify the steps:
————————————————————————————————-
From viitoria:Here’s what I did when I got just about every single problem posted on this page.
1) Make a .htaccess file, but leave it blank.
2) Upload it into the directory your WP index.php page is.
3) Change chmod of the .htaccess to 777
4) Update permalinks
5) Change chmod of .htaccess back to 644 (for your own protection)It should work now. Hope this helps.
————————————————————————————————-
————————————————————————————————-
From TimI’ve struggled with this for a couple of days and finally got it to work using exactly the same steps as the poster above but with the addition of one step:
4b) edit the .htaccess file generated by wordpress and add the line Options +Followsymlinks so that the first three lines of this file now read:
<IfModule mod_rewrite.c>
Options +Followsymlinks
RewriteEngine On(There’s no point adding this line before WP updates the .htaccess file: you addition will just be overwritten.)
This is assuming of course that Apache is configured to allow .htaccess files. You need AllowOverride to be set to All in your /etc/apache2/httpd.conf and .htaccess to be defined as the name of the file that can override the default settings. The section should look something like this:
<Directory />
Options None
AllowOverride All
Order deny,allow
Deny from all
</Directory># use .htaccess files for overriding,
AccessFileName .htaccessHope this helps someone
Tim
————————————————————————————————-
I should add that further instructions for implementing step 4 can be found at the Options/Permalinks menu within Wordpress. There are many suggestions and opinions about the exact structure for permalinks. At the very least, include the post name. Another recommendation can be found here.






[...] .htaccess and WordPress [...]
August 2nd, 2005 at 2:36 am[...] One of the most popular pages on this site is a post I wrote about htaccess and Wordpress. [...]
August 25th, 2006 at 3:23 pmThanks for the helpful post!
September 22nd, 2006 at 9:13 amFinally, I could solve my problem.
[...] I got the reason behind my error and the solution I needed. A big thanks and cyber hug to this post and to viitoria for the [...]
June 6th, 2007 at 11:32 pmI have an Windows based server and are using IIS 6 instead of Apache. Do you have any idea of what i should do to change my permalinks. I get an error when i change the default permalink.
July 16th, 2007 at 5:58 amVery good tutorial! The only one that solved my problem!
Thanks
September 14th, 2007 at 11:16 amYou’re welcome Alessandra!
September 26th, 2007 at 5:52 pm