Default .htaccess file for WordPress?

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?

Related posts

Leave a Reply

4 comments

  1. 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]
    </IfModule>
    # END WordPress
    

    you can check it here for default htaccess file.

    http://codex.wordpress.org/Using_Permalinks.

    Thanks. I hope it helps little.

  2. 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.

  3. 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.

    intercepting

    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'.
    

    Related

    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.