htaccess 重写到没有 301 的子目录

htaccess rewriterule to subdirectory without 301

我有一个关于 RewriteRule with .htaccess without 301 的问题。 在我的目录结构下面:

 -root
 --public
 --app

在根目录中我有一个目录 publicapp。 在目录 public 中,我有一个 index.php 文件。

在根目录中我有一个 .htaccess 文件,我希望所有流量都到达 public.

目录中的 index.php 文件

我尝试过的:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/public/ [NC]
RewriteRule ^(.*)$ public/index.php?url= [L,QSA]

重写没有任何作用,我从目录中看到了索引

谁能帮帮我?

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/public/ [NC]
RewriteRule ^(.*)$ public/index.php?url= [L,QSA]

您需要删除检查请求的 URL 路径是否开始 /public/ 的第三个条件。据推测,您正在发出类似 /foo 的请求,因此这种情况将阻止规则执行任何操作。