Regex .htaccess重写引擎、文件夹结构、,

Regex .htaccess重写引擎、文件夹结构、,,regex,apache,.htaccess,mod-rewrite,directory-structure,Regex,Apache,.htaccess,Mod Rewrite,Directory Structure,有以下文件夹结构 公开的 .htaccess index.php 和.htaccess结构如下 RewriteEngine On # The following rule tells Apache that if the requested filename # exists, simply serve it. RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR]

有以下文件夹结构

    • 公开的
      • .htaccess
      • index.php
和.htaccess结构如下

RewriteEngine On


# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

# The following rewrites all other queries to index.php. The 
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to 
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size 
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
问题访问时,它会显示文件夹结构以使其正常工作,我需要访问它


问题如何使访问成为?

您需要在根级别(高于
公共
的级别)拥有.htaccess才能将所有流量转发给公共:

RewriteEngine On
RewriteBase /

RewriteRule ^(.*)$ public/$1 [L]

不需要在
/public/.htaccess

中进行任何更改。在根级别添加了.htaccess并编写了您的代码,但我似乎无法工作。然后,我删除了所有代码,并随机编写了文本来检查它是否有效,服务器是否可以看到.htaccess。