Apache mod_rewrite clashing with wordpress rule

Sam Ducker asked
wordpress apache mod-rewrite
via

I have a page outside of the Wordpress installing but located in the root directory at v1.html

I’ve tried a few different mod_rewrite rules but they all seem to clash with the WordPress .htaccess rules. How can I keep my wordpress installation in tact but also have /v1.html renamed to /v1 without 404ing

    # 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 


Answer
via

Add your rule before the WordPress block and use the [L] to stop on your rule when it matches. This way it doesn’t trickle into the WordPress rules.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^v1/?$ /v1.html [L]
</IfModule>

# 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
Share This
Posted in: