Resetting WordPress Permalinks

If you have been using WordPress and use clean URLs, you may notice that changing the .htaccess file can cause all of your links to return a 404 error. This is because permalinks are rewrites in the .htaccess file itself. When you change the location of an install or create a new .htaccess file, you need to reset the permalinks.
Resetting the permalinks is fairly easy and can be done in two ways:
The first method is done in the wordpress dashboard, the second in the database. First, you will need to log into your wordpress dashboard. On the left under settings, you will see a link for permalinks.

When you click on that link, you will see the common settings:

The default one doesn’t look the most pretty, so I use a custom setting to just use the post name. To reset the permalinks, just click the “Save Changes” link at the bottom of the page. This will write to the .htaccess file for you.

The second way to change your permalinks is to modify the permalink_structure row in the wp_options table in your database. At bluehost, this is just a matter of logging into the phpmyadmin tool and selecting the correct database for your install. When you have the db selected, you will see a list of all of the tables in the database:

Click on the browse link next to wp_options to see the rows in the table.

Now you will see all the rows in this table. You will need to search until you find the permalink_structure row. For me it is row 33, though it varies. Click on the edit icon (looks like a pencil) to change the setting.

The big block is where you will enter the new structure. You will need to know the proper permalink structure to change this. Here are the different tags to use:

%year%
The year of the post, four digits, for example 2004

%monthnum%
Month of the year, for example 05

%day%
Day of the month, for example 28

%hour%
Hour of the day, for example 15

%minute%
Minute of the hour, for example 43

%second%
Second of the minute, for example 33

%post_id%
The unique ID # of the post, for example 423

%postname%
A sanitized version of the title of the post (post slug field on Edit Post/Page panel). So “This Is A Great Post!” becomes this-is-a-great-post in the URI (see Using only %postname%). Starting Permalinks with %postname% is strongly not recommended for performance reasons.

%category%
A sanitized version of the category name (category slug field on New/Edit Category panel). Nested sub-categories appear as nested directories in the URI. Starting Permalinks with %category% is strongly not recommended for performance reasons.

%tag%
A sanitized version of the tag name (tag slug field on New/Edit Tag panel). Starting Permalinks with %tag% is strongly not recommended for performance reasons.

%author%
A sanitized version of the author name. Starting Permalinks with %author% is strongly not recommended for performance reasons.

You must use /tag/ in order for it to work, as well. When you make the change, click “Go” and you’re all set.

You will also need to edit the .htaccess file to include the proper rewrite rules if you change the permalinks in the database only.  Here is the code you need to use:

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

# END WordPress

When you finish, refresh your site to see the changes. You may need to clear your cache.