【问题标题】:.htaccess rewrite everything to index.php except scripts in a specific folder.htaccess 将所有内容重写为 index.php,特定文件夹中的脚本除外
【发布时间】:2019-08-28 12:10:47
【问题描述】:

我有两个可公开访问的文件夹:

/public
/legacy

现在我想将所有请求重定向到 /public/index.php,但以 /legacy 开头的请求除外:

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

目前我只有以下 .htaccess 文件:

/:

Order deny,allow
Deny from all

/public 和 /legacy:

Order allow,deny
Allow from all

【问题讨论】:

  • 到目前为止你尝试过什么?你被困在哪里了?

标签: apache .htaccess


【解决方案1】:

你可以试试这个mod_rewrite 规则

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-12-07
    • 2016-03-12
    • 2018-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多