Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.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
.htacess用于删除public/index.php在根目录中效果良好,而不是在子目录中_Php_Regex_.htaccess_Mod Rewrite_Rewrite - Fatal编程技术网

.htacess用于删除public/index.php在根目录中效果良好,而不是在子目录中

.htacess用于删除public/index.php在根目录中效果良好,而不是在子目录中,php,regex,.htaccess,mod-rewrite,rewrite,Php,Regex,.htaccess,Mod Rewrite,Rewrite,这是我的.htaccess,我在laravel中有默认设置,它帮助我防止键入public/index.php <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On RewriteRule ^(.*)/$ /$1 [L,R=301] RewriteCond

这是我的
.htaccess
,我在laravel中有默认设置,它帮助我防止键入
public/index.php

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>
    RewriteEngine On
    RewriteRule ^(.*)/$ /$1 [L,R=301]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
我打字就够了

localhost/home
localhost/login
我想对“testproject”和“betaproject”等少数目录例外,即我将有一个常规的php或html目录,或者我将有另一个新项目,它也将有相同的.htaccess

如何修改.htaccess文件使之成为可能。

所以如果我想访问


localhost/testproject/public/index.php/home
应该可以通过根目录中的
localhost/testproject/home
访问。htaccess有此规则跳过两个目录:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(testproject|betaproject)/(\w+)/?$ $1/public/index.php/$2 [L,NC]
请确保此规则位于行的
重写引擎的正下方

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(testproject|betaproject)/(\w+)/?$ $1/public/index.php/$2 [L,NC]