htaccess RewriteRule导致404

We have a main site in a subdirectory where our main domain is pointed and a lot of sites in root subfolders. some of they are subdomains.

main site (laravel install):

public_html/mainsite/default/public/index.php

secondary sites

public_html/rec/index.php
public_html/raesta/index.php
public_html/acrup/index.php

htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(acrup) - [L]
    RewriteRule ^(raesta) - [L]
    RewriteRule ^(rec) - [L]
    RewriteRule ^(.*)$ mainsite/default/public/$1 [L]
</IfModule>

The main site domain is http://mainsite.edu.ar

The problem is when we try to access http://mainsite.edu.ar/recursos returns 404

It seems it's matching the /rec part of the url

we already tried:

RewriteRule ^(rec)/?$  - [L]

resulting in: http://mainsite.edu.ar/recursos works but http://mainsite.edu.ar/rec doesn't

http://mainsite.edu.ar/raesta and http://acrup.mainsite.edu.ar both works fine

Maybe try this instead:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^/acrup/ - [L]
    RewriteRule ^/raesta/ - [L]
    RewriteRule ^/rec/ - [L]
    RewriteRule ^(.*)$ mainsite/default/public/$1 [L]
</IfModule>

Your first try

RewriteRule ^(rec) - [L]

was hit by http://mainsite.edu.ar/recursos as well as http://mainsite.edu.ar/rec because both URIs (everything after the DNS-name mainsite.edu.ar) start with rec.

Your second take

RewriteRule ^(rec)/?$  - [L]

didn't work, becuase you made the trailing slash optional with /? so still both URIs were hit.

The difference with RewriteRule ^/rec/ - [L] is that it explicitly requires /rec/ --> a leading and trailing slash surrounding rec.