My .htaccess files are intercepting WordPress' .htaccess file.

Which modules and which settings (specified by .htaccess) are required for WordPress to work? In other words, where can I find WordPress' default .htaccess file?


4 Answers 4


Here is the default code for that file.

# 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]
# END WordPress

you can check it here for default htaccess file.


Thanks. I hope it helps little.


WordPress does not contain .htaccess in file form.

The rules are written into file by save_mod_rewrite_rules() function and are generated by $wp_rewrite->mod_rewrite_rules().

Note that multisite installation has different (more complex) rules and seems to be handled differently.

  • +1 for the right direction. Please, review whether I understood the issue right with my answer. I think the central thing is just to use the Rewrite_WP API, not to reinvent the wheel with personal .htaccess -files.
    – user14016
    Apr 22, 2012 at 10:42

Use the latest version of default .htaccess



Use the Freenode's #wordpress to find the appropriate documentation, usually in the /topic. There I found the key Class WP_Rewrite here, the official wordpress.org is at the best misleading and marketing. Anyway, do not mix Apache's rewrite rules with WP's rewrite rules although the naming of WP is probably from Apache's equivalent.

The WP_Rewrite API states

You can add rules to trigger your page view and processing using this component. The full functionality of a front controller does not exist, meaning you can't define how the template files load based on the rewrite rules.

so you must use the API to do the changes, not fully sure what it means but I think it means you cannot trust in your hard-coded .htaccess -files -- things may change even with different WD -versions! So use the API.


The code here has some conditions if the .htaccess -file exists -- not 100% of their inferences because not well-documented and cannot understand the naming there but the central message is probably that the safe way to maintain the rewrite rules is to use the WP_Rewrite API, WP may change in the future.

For example, a simple Apache-rewrite RewriteRule ^hello$ Layouts/hello.html [NC,L] is apparently something like add_rewrite("^hello$", "Layouts/hello.html"), haven't tested but tried to follow the API below:

add_rewrite_rule (line 19)
Add a straight rewrite rule.

see: WP_Rewrite::add_rule() for long description.
since: 2.1.0
void add_rewrite_rule (string $regex, string $redirect, [string $after = 'bottom'])
string $regex: Regular Expression to match request against.
string $redirect: Page to redirect to.
string $after: Optional, default is 'bottom'. Where to add rule, can also be 'top'.


  1. http://codex.wordpress.org/Rewrite_API/add_rewrite_rule

  2. http://pmg.co/a-mostly-complete-guide-to-the-wordpress-rewrite-api

  3. Thanks to toscho for assisting here, some small-talk in chat.

  • I am quite sure I have misunderstood here something, please, review this chat here. Did it intercept because my blog was on root -level meaning something like www.hello.com/blog/?
    – user14016
    Jun 6, 2012 at 3:33