如何重写以下URL改变,让更多的子文件夹,当所有的URL重定向到索引页?有的、重写、文件夹、重定向

2023-09-02 11:28:05 作者:雪花飘飘的天空

我试图改变以下重写规则,以接受更多的文件夹。目前任何其他URL其他 mydomain.com 测试将被引导到的index.php

 重写规则^((?!测试)。)* $的index.php [QSA,L]
 

我需要添加更多的子文件夹,比如测试1 测试2 等,让我可以访问网址 test1的 测试2 等。

重写规则

  RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME!-f
重写规则^((?!测试)。)* $的index.php [QSA,L]
 

解决方案

嗯......

权限写入是灰色的怎么办除啊 win10系统

您已经也符合什么 / test1的 /测试2 因为你只有正则表达式检查的东西没有按'T开始以 /测试,都 / test1的 /测试2 开始 /测试

但是,如果你想让它检查不都开始用同样的多个文件夹,然后使用 | 在EX pression。假如你还想要排除 /等等 /的Bleh

 重写规则^((?!测试|等等。|的Bleh))* $的index.php [QSA,L]
 

I am trying to change the below rewrite rule to accept more folders. Currently any other url else mydomain.comtest will be directed to index.php.

RewriteRule ^((?!test).)*$ index.php [QSA,L]

I need to add more subfolders like test1, test2 etc. So that I can access url test1, test2 etc.

Rewrite Rule

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

解决方案

Well...

What you have already also matches /test1 and /test2 because the regex you have only checks that something doesn't start with /test, and both /test1 and /test2 starts with /test.

But if you want it to check multiple folders that don't all start with the same thing, then use the | in the expression. Say you also want to exclude /blah and /bleh:

RewriteRule ^((?!test|blah|bleh).)*$ index.php [QSA,L]