简体   繁体   English

htaccess mod_rewrite阻止执行php文件

[英]Htaccess mod_rewrite preventing execution of php files

I'm having trouble with a htaccess mod_rewrite preventing php files from being executed directly. 我在使用htaccess mod_rewrite时遇到麻烦,无法直接执行php文件。

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. 该站点似乎正在MVC框架上运行(不幸的是,不能100%地确定使用哪个MVC框架),并且正在通过路由器类发送请求。 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: 这是我当前的htaccess文件:

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? 有什么办法可以直接在subdir中执行php文件? Any help would be much appreciated, thanks. 任何帮助将不胜感激,谢谢。

Have you tried with RewriteCond %{REQUEST_URI} !^/subdir/ ? 您是否尝试过RewriteCond %{REQUEST_URI} !^/subdir/吗? The REQUEST_URI may start with a / . REQUEST_URI可以以/开头。

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 如果收到错误500,请检查脚本中是否存在致命错误/未捕获的异常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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