简体   繁体   English

.htaccess重写规则将所有内容从子文件夹重定向到另一个文件夹

[英].htaccess rewrite rule redirect all from subfolder to another folder

I have a problem with my .htaccess rules. 我的.htaccess规则有问题。 I have the following scenario: before changes in my root I had a folder named "eleague" and everything worked fine. 我有以下情况:在更改根目录之前,我有一个名为“ eleague”的文件夹,并且一切正常。 Now I have another folder (in the root) named "competitions" and a .htaccess(in root) file where I wrote some rules, something like these: 现在,我有另一个名为“ competitions”的文件夹(在根目录中)和一个.htaccess(在根目录中)文件,在其中写入了一些规则,如下所示:

RewriteRule ^aleague/(.*)-(\d+).html.*$                 /competitions/competition.php?t_id=$2&text=$1  [L]
RewriteRule ^bleague/(.*)-(\d+).html.*$                 /competitions/competition.php?t_id=$2&text=$1  [L]
...
RewriteRule ^eleague/(.*)-(\d+).html.*$                 /competitions/competition.php?t_id=$2&text=$1 [L]

What I want now is to modify .htaccess file from "eleague" folder to redirect all requests to my new location (last rule above to be matched). 我现在想要的是从“ eleague”文件夹中修改.htaccess文件,以将所有请求重定向到我的新位置(上面要匹配的最后一条规则)。 The trick is that I cannot (It`sa must!!) REMOVE the "eleague" folder from my directory structure. 诀窍是我不能(一定要!)从我的目录结构中删除“ eleague”文件夹。

如果要在浏览器栏中显示新的URL,则必须在规则中添加重定向R标志

RewriteRule ^eleague/(.*)-(\d+).html.*$ /competitions/competition.php?t_id=$2&text=$1 [R,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM