[英]Prevent .php files from being redirected with htaccess
Because of a node.js instance I have set up the following entry in my .htaccess file: 由于有一个node.js实例,我在.htaccess文件中设置了以下条目:
RewriteRule ^(.*)$ http://localhost:65432/$1 [P]
A webserver is up and running which could render PHP files. Web服务器已启动并正在运行,该服务器可以呈现PHP文件。 This is not possible if those are being loaded from the node.js instance.
如果是从node.js实例加载的,则不可能。 Now I want to add another rule before the proxy to compute all .php files without looping through the node.js proxy.
现在,我想在代理之前添加另一条规则来计算所有.php文件,而无需遍历node.js代理。 I have tried it with
我尝试过
RewriteRule ^(.*).php ^(.*).php [L]
but that doesn't work. 但这不起作用。 How can this problem be solved?
如何解决这个问题? Thanks
谢谢
To use a requested URI unchanged, you must use a - (dash)
要使用不变的请求URI,必须使用
- (dash)
- (dash)
-(破折号)
A dash indicates that no substitution should be performed (the existing path is passed through untouched).破折号表示不应执行任何替换(现有路径未经修改地传递)。 This is used when a flag (see below) needs to be applied without changing the path.
当需要在不更改路径的情况下应用标志(请参阅下文)时,将使用此方法。
So your rule should look like 所以你的规则应该看起来像
RewriteRule \.php$ - [L]
which means, when a URI ending in .php
is requested, do nothing and stop further processing. 这意味着,当请求以
.php
结尾的URI时,不执行任何操作并停止进一步处理。
要从代理重定向中排除.php文件,可以使用以下规则
RewriteRule ((?!\.php).*)$ http://localhost/$1 [P]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.