简体   繁体   中英

Htaccess redirect exclude subfolder

I have application in Laravel and also another folder in public_html that I want to exclude from Laravel's redirection.

For example in public_html I have folder staff/

I want to exclude redirection for all files and folders in that folder so if someone tryes to access

domain.com/staff/index.php or domain.com/staff/folder1/ to actually looks into that directory.

For now my htaccess is like this:

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Exclude directory from rewriting
RewriteRule ^(staff) - [L]

# Redirect Trailing Slashes
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

This works for domain.com/staff it actually opens the index.php in staff/ instead of laravel index.php in root directory. but with this if I go to /staff/folder/ it uses Laravel.

How to exclude directory with all subfolders and files from laravel router?

您可以使用正则表达式来匹配完全匹配staff或以staff/开头的请求,如下所示:

RewriteRule ^staff($|/) - [L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM