简体   繁体   中英

Htaccess mod_rewrite preventing execution of php files

I'm having trouble with a htaccess mod_rewrite preventing php files from being executed directly.

The site seems to be running on an MVC framework (not 100% sure on which one unfortunately) and requests are being sent through a router class. I have a subdirectory which I want to exclude from the routing and have its files be executed directly.

Here is my current htaccess file:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]

I have tried excluding the subdirectory I want to execute directly with the following line but it made no difference:

RewriteCond %{REQUEST_URI} !^subdir/(.*)

Is there any way I can execute the php files in subdir directly? Any help would be much appreciated, thanks.

Have you tried with RewriteCond %{REQUEST_URI} !^/subdir/ ? The REQUEST_URI may start with a / .

RewriteCond %{REQUEST_FILENAME} !-f

This line allows you to execute files directly. If you are getting error 500, check your scripts for fatal errors / uncaught exceptions

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