Support » Networking WordPress » Exclude folder – htaccess

  • Resolved web2033

    (@web2033)


    Hi!

    I need to exclude 1 folder (and all subfolders and files inside) in the root, say “folder” so it works without WP.
    I have subdirectories based Network with standard .htaccess:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    What’s missing here? Because subfolders are still shown by WP…

    RewriteEngine On
    RewriteBase /
    RewriteRule ^/folder($|/) - [L] 
    RewriteRule ^index\.php$ - [L]
Viewing 2 replies - 1 through 2 (of 2 total)
  • You can add a single rule:

    RewriteRule ^(folder)($|/) – [L]

    Place that after the RewriteBase / line

    That says if you match that rule stop executing more rules. You can see other rules like it at the bottom of the list set to bypass wp-content, etc.

    You can read this page for more info.

    It works! Thanks @smithjw1

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.