Open unikoca opened 1 year ago
From what I know traditional routes should also work fine, let say you have file feature.php in folder abc
domain.com/abc/feature.php should also work
It's doesn't seems to work in my case, since everything is passing thru index.php (router) already, loading config, etc... within the htaccess file. Some conflics occurs.
i may put the entire routing in a if/else statement but it's not very clean... Better ways are welcome. 👍
Requests to existing files and folders should be delivered directly without going through the index.php. There are rules to achieve this inside the .htaccess:
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d
You can test this rules: Place a file (test.txt) into your root folder and try to call it: https://mydomain.com/test.txt You should then see its contents. Also you can place such a file into your sub folder and then call https://mydomain.com/abc/test.txt Both request should bypass the router. If this does not work you should check your .htaccess file. Maybe it was modified?
I think I wasn't clear enough... I'm not talking about accessing a particular file within the /abc/ folder.
note that the first regex will glab all the possible paths & files on the root and the subfolders. It is useful when you create folders from an admin panel for example.
could be useful to have an 'exclude' method to remove a file/path from the possibilities.
3 ways you can achieve that @unikoca
use of regexp: ^(?!.(?:admin|other_word|yet_another)).[a-zA-Z0-9-/]+.*$ (Recommended)
Route::add('/(^(?!.*(?:admin|other_word|yet_another)).*[a-zA-Z0-9-/]+.*$)', function() {
return 'admin and some words not allowed';
});
You can even go further to define which words to begin with in your route
add another parameter function of type array or string on the add function, and handle any words or expressions you don't want on the specific route
If you're using Apache web server, use .htaccess to set custom rules
Hi,
On a particular project, i'm using your library on the root of the domain, everything works fine. But now, they install a folder ( ex: /abc/ ) that doesn't need to be managed by your routing. Is there a way to 'exclude' a folder from your routing?
Regards,