本文介绍了如何重写以下URL改变,让更多的子文件夹,当所有的URL重定向到索引页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图改变以下重写规则,以接受更多的文件夹。目前任何其他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]
 

解决方案

嗯......

您已经也符合什么 / 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.com\test 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]

这篇关于如何重写以下URL改变,让更多的子文件夹,当所有的URL重定向到索引页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 12:48