Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php htaccess重定向(如果不以文件夹开头)_Php_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

Php htaccess重定向(如果不以文件夹开头)

Php htaccess重定向(如果不以文件夹开头),php,.htaccess,mod-rewrite,url-rewriting,Php,.htaccess,Mod Rewrite,Url Rewriting,我想创建一个白名单文件夹,并将所有其他请求重定向到索引 url.com/public/.* <-- Can access to file on public folder url.com/xxxx <-- redirect to index.php url.com/public/*试试: 不,因为我可以访问url.com/i\m\u a\u机密文件和现有文件是的,它可以工作!实际上,通过将RewriteBase/添加到我的htaccess中,500错误就消失了 <IfModu

我想创建一个白名单文件夹,并将所有其他请求重定向到索引

url.com/public/.* <-- Can access to file on public folder
url.com/xxxx <-- redirect to index.php
url.com/public/*试试:


不,因为我可以访问
url.com/i\m\u a\u机密文件和现有文件
是的,它可以工作!实际上,通过将
RewriteBase/
添加到我的htaccess中,500错误就消失了
<IfModule mod_rewrite.c>

    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    RewriteRule !^public/.* index.php [L,NC]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

</IfModule>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteRule !^public /index.php [L]