简体   繁体   中英

.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:

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

currently I only have the following .htaccess files:

/:

Order deny,allow
Deny from all

/public and /legacy:

Order allow,deny
Allow from all

You could try this mod_rewrite rule

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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