exclude folder in wordpress using htaccess failed

I created a folder named folder1 after entering the root. At that level of directory there’s my .htaccess, I googled and I paste the following line at

..
RewriteRule ^index.php$ - [L]
// this
RewriteCond %{REQUEST_URI}  !(folder1|folder2|folder3) [NC]

RewriteCond %{REQUEST_FILENAME} !-f
..

But when I go to mydomain.com/folder1, it returned 404 of my wordpress?

Related posts

Leave a Reply

2 comments

  1. You should post all of your code so that we can make sure there aren’t other rules conflicting. Not just the part you can’t get working.

    Try using THE_REQUEST and try it this way and put it above your wordpress rules. So if it matches then do nothing.

    RewriteCond %{THE_REQUEST} ^(GET|POST) /(folder1|folder2|folder3) [NC]
    RewriteRule ^ - [L]
    
  2. I found this, exclude subfolder with wordpress .htaccess and workds for me.
    I put this before WordPress rules:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^/yoursubdirectoryname1/(.*)$
    RewriteRule ^.*$ - [L]
    </IfModule>
    

    and here is WordPress rules:

    # 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
    

    My complete .htaccess code:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^/yoursubdirectoryname1/(.*)$
    RewriteRule ^.*$ - [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
    

    source: I found this code on WordPress forum.