简体   繁体   English

.htaccess将所有内容重写为index.php,但特定文件夹中的脚本除外

[英].htaccess rewrite everything to index.php except scripts in a specific folder

I have two publicly accessible folders: 我有两个可公开访问的文件夹:

/public
/legacy

Now I want redirect all requests to /public/index.php except those that start with /legacy: 现在,我希望将所有请求重定向到/public/index.php,但以/ legacy开头的请求除外:

/users --> /public/index.php
/legacy/somescript.php --> /legacy/somescript.php

currently I only have the following .htaccess files: 目前,我只有以下.htaccess文件:

/: /:

Order deny,allow
Deny from all

/public and /legacy: / public和/ legacy:

Order allow,deny
Allow from all

You could try this mod_rewrite rule 您可以尝试使用此mod_rewrite规则

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(legacy/.*)$
RewriteRule . /public/index.php [L]

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

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