Where does wordpress store htaccess rewrite rules?

If you are thinking for one second the rules are stored in .htaccess in the wordpress folder, you are totally wrong. Infact these rules are stored in mysql database in the wp_options table under rewrite_rules field.

Checkout this site for complete list of wordpress 2.x rewrite rules

Although it is common for most php related applications save all the rules in htaccess files, it is not the case with wordpress.

which is why you will see only the default rules when you open .htaccess file. All the permalinks and rewrite rules are stored in database.


RewriteEngine On
RewriteBase /
RewriteRule ^go/([0-9]+)/$ /index.php?go=$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

If you are a wordpress plugin developer and often you might want to add custom rewrite rules for your plugin. For that there is a separate WP_Rewrite class

For more wordpress documentation on rewrite rules, be sure to checkout WordPress custom queries and Query overview.

You can decode and see the rewrite rules using the Rewrite rules viewer plugin. You might need this while developing your custom rewrite rules.