.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.
Posted by Paul Flyer on Wednesday, May 25th, 2005 in WordPress Help




gyrmination » Blog Archive » WordPress Wonder Says:
August 2nd, 2005 at 2:36 am
[...] .htaccess and WordPress [...]
» htaccess Tutorial for beginners :: Recommended Web Tools Says:
August 25th, 2006 at 3:23 pm
[...] One of the most popular pages on this site is a post I wrote about htaccess and WordPress. [...]
Michi Says:
September 22nd, 2006 at 9:13 am
Thanks for the helpful post!
Finally, I could solve my problem.
WordPress, PermaLink, .htaccess and 500 Internal Server Error | HUMVOX Says:
June 6th, 2007 at 11:32 pm
[...] 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 [...]
Anita Says:
July 16th, 2007 at 5:58 am
I 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.
Alessandra Says:
September 14th, 2007 at 11:16 am
Very good tutorial! The only one that solved my problem!
Thanks
Paul Flyer Says:
September 26th, 2007 at 5:52 pm
You’re welcome Alessandra!
Aksatech Says:
December 2nd, 2009 at 12:23 am
I tried to change the permalink structure to custom structure. Once i clicked on the Save chages button, I got an “500 Internal Server Error”.
My blog posts are not opening. Also I am not able to restore to the default settings. Is it because of the .htaccess file or because of a windows server.
I need to restore to the default settings. Kindly suggest
Mike Says:
January 21st, 2010 at 4:16 pm
I am currently dealing with a site hosted on Yahoo. This has not been a good experience…
From the Yahoo help source:
“Yahoo! does not currently allow you to upload .htaccess files to your account.”
Any thoughts?
What the heck is a .htaccess file (and why is my blog messed up?) « Web Tools For The Digital World Says:
May 23rd, 2010 at 11:43 pm
[...] turning complicated URLs to more memorable (“pretty”) ones. This is why .htaccess most causes trouble in WordPress with permalinks– my experience [...]