[英]Write an .htaccess rewrite rule excluding one file
I'm working with a framework and need to make a call to a specific file within a directory, however the directory is set up for url of all requests to index.php for the framework's sake. 我正在使用框架,需要调用目录中的特定文件,但是为了框架的缘故,该目录是针对对index.php的所有请求的URL设置的。
I have a file called check-session.php
and need any requests to localhost/admin/check-session.php
to execute the actual check-session.php file instead of route to index.php
. 我有一个名为
check-session.php
的文件,需要对localhost/admin/check-session.php
任何请求才能执行实际的check-session.php文件,而不是路由至index.php
。 How do I do that with .htaccess file within the same folder as check-session.php
? 如何使用与
check-session.php
相同的文件夹中的.htaccess文件执行此操作?
I have little to no experience with rewrite rules / conditions. 我几乎没有重写规则/条件的经验。
Find the RewriteRule that rewrites to index.php and put these directly before it: 找到重写为index.php的RewriteRule并将其直接放在其前面:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !\.php$
That should stop it mapping to index.php if it's a real file you request. 如果它是您请求的真实文件,则应停止将其映射到index.php。
If that doesn't work, post the actual rewrites in .htaccess 如果这样不起作用,请在.htaccess中发布实际的重写
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.