[英]RewriteCondition in .htaccess except for one folder?
I would like to do the following:我想做以下事情:
I have a htaccess file that makes every request go trough index.php
.我有一个 htaccess 文件,它使每个请求都通过index.php
。 If I am not mistaken this is called bootstrapping?如果我没记错的话,这叫做引导? (I haven't done this before). (我以前没有这样做过)。
I would like to make a subdirectory in the root directory of the site that will serve as a "test" site because I cannot add a subdomain.我想在站点的根目录中创建一个子目录作为“测试”站点,因为我无法添加子域。 I need a htaccess rewritecond that will redirect any request under the teszt
folder to the index.php
in the same folder.我需要一个 htaccess rewritecond,它将teszt
文件夹下的任何请求重定向到同一文件夹中的index.php
。
So if I enter example.com/[anything]
I get data sent to the index.php
in the root and if I enter example.com/teszt/[anything]
, the data needs to be sent to teszt/index.php
因此,如果我输入example.com/[anything]
我将数据发送到根目录中的index.php
,如果我输入example.com/teszt/[anything]
,则需要将数据发送到teszt/index.php
This is my htaccess file:这是我的 htaccess 文件:
IndexIgnore *
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
You can use these rules in htaccess in your root folder :您可以在根文件夹的 htaccess 中使用这些规则:
RewriteEngine On
#rewrite /subfolder/foobar to /subfolder/index.php
ReweriteRule !subfolder/index\.php /subfolder/index.php [L]
#rewrite /foobar to /index.php
RewriteRule !index\.php /index.php [L]
The rules above also rewrites your existent files to index.php .上面的规则还将您现有的文件重写为 index.php 。 If you do not want to rewrite your files , just add a condition to the rule RewriteCond %{REQUEST_FILENAME} !-f
.如果您不想重写文件,只需在规则RewriteCond %{REQUEST_FILENAME} !-f
中添加一个条件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.