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