Exclude wordpress from .htaccess rules

I have a testing web where there is a testing directory lets say ‘test’ which contains wordpress directory lets say ‘mywordpress’, test and his content – excluding the mywordpress – is handled by its own .htaccess – I need the .htaccess to do nothing with the url that goes mydomain.com/test/mywordpressXX (XX can be “/” or “/anything….”

Ive tried something but this .htaccess still works with test content, but throws Internal 500 error when I am trying to reach WP admin:

Read More
RewriteEngine On
RewriteBase /test/

DirectorySlash On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/.]+)$ $1/ [R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/mywordpress/?$
RewriteRule ^([^/?]+)$ $1.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/mywordpress/?$
RewriteRule ^([^/?]*)/([^/?]*)$ $1.php?$1=$2

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/mywordpress/?$
RewriteRule ^([^/?]*)/([^/?]*)/([^/?]*)$ $1.php?$2=$3

What am I doing wrong? Or how is it done correctly ?

Thanks.

Related posts

Leave a Reply

2 comments

  1. Try this .htaccess:

    DirectorySlash On
    
    RewriteEngine On
    RewriteBase /test/
    
    RewriteRule ^mywordpress(/|$) - [NC,L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/.]+)$ $1/ [L,R]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/?$ $1.php [L,QSA]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/([^/]*)/?$ $1.php?$1=$2 [L,QSA]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/([^/]+)/([^/]*)/?$ $1.php?$2=$3 [L,QSA]
    
  2. Oh ! Silly me ! I forget about the RewriteBase /test/ you just have to make the exclude rule this way:

    RewriteCond %{REQUEST_URI} !mywordpress/?$
    

    There was an additional slash:

    RewriteCond %{REQUEST_URI} !/mywordpress/?$