.htaccess Directives To *not* Redirect Certain URLs
In an application that heavily relies on
.htaccess RewriteRules for its PrettyURLs (CakePHP in my case), how do I correctly set up directives to exclude certain directories from this rewriting? That is:
/appRoot/.htaccess app/ static/
By default every request to
/appRoot/* is being rewritten to be picked up by
app/webroot/index.php, where it's being analysed and corresponding controller actions are being invoked. This is done by these directives in
RewriteBase /appRoot RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L]
I now want to exclude a few directories like static/ from this rewriting. I tried with this before the Cake RewriteRules:
RewriteCond $1 ^(static|otherDir).*$ [NC] RewriteRule (.*) - [L]
It works in so far that requests are no longer rewritten, but now all requests are being skipped, even legitimate Cake requests which should not match
I tried several variations of these rules but can't get it to work the way I want.
And the correct answer iiiiis...
RewriteRule ^(a|bunch|of|old|directories).* - [NC,L] # all other requests will be forwarded to Cake RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L]
I still don't get why the index.php file in the root directory was called initially even with these directives in place. It is now located in
and handled through Cake as well. With this in place now, I suppose this would have worked as well (slightly altered version of Mike's suggestion, untested):
RewriteCond $1 !^(a|bunch|of|old|directories).*$ [NC] RewriteRule ^(.*)$ app/webroot/$1 [L]
- → Laravel 5: Apache php http authentication
- → Htaccess negation
- → OctoberCMS error in frontend - frontend is not accessible firing error "Default value for parameters with a class type hint can only be NULL"
- → How to give access execute specific php file in server?
- → 301 Redirection from no-www to www in wordpress
- → Cyclical redirection at the start laravel 5 project
- → Can't route in Laravel framework
- → How to benefit of prerender.io services if my Apache server doesn't allow a proxy
- → OctoberCMS installation MYSQL error
- → Redirect 301 htaccess prestashop
- → Permissions "public" folder Laravel
- → .htaccess affect other file url
- → How i can redirect from "www.mywebsite.com////" to "www.mywebsite.com"?