WordPress mod_rewrite exception for a subdirectory

I am using GoDaddy Delux Hosting, Linux server. I have a wordpress installation in the root directory. I’ve started a development directory under the root directory. I don’t have a wordpress installation under the development directory, but my own project.

My objective is to circumvent wordpress url rewriting just for the development directory, and redirect every url that starts with the development directory to development/index.php. I have experimented with numerous mod_rewrite combinations, but I couldn’t get it work. I get the standard wordpress “page not found” page for everything except mysite.com/development/index.php

Read More

The last configuration I’ve come up with is the following:

root directory .htaccess file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(development|development/.*)$
RewriteRule . /index.php [L]
</IfModule>

development directory .htaccess file:

RewriteEngine On
RewriteRule .* index.php [L]

Any ideas how to best approach this?

PS: I haven’t used “development” in WordPress as a slug.

Related posts

Leave a Reply

1 comment

  1. In the main .htaccess file you should ignore anything under “development” – you don’t need the initial forward slash because of RewriteBase / and you can make the trailing slash optional with a ?, and there is no need for .*$.

    In the subdirectory you ignore anything not in the subdirectory for rewrites using RewriteBase /development/ sending everything to /development/index.php where the request is not a file or directory.

    Give the following a try:

    /.htaccess

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

    /development/.htaccess

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