【发布时间】:2026-02-14 18:05:02
【问题描述】:
我已经问过这个问题但没有答案。
我开发了新论坛,所以我将一些文件,如索引、登录、注册等...放在名为 webroot 的子目录中,我想将所有请求重定向到 webroot 而不直接访问它,例如:
localhost/myforum [根项目文件] 应该可以正常访问,但是
localhost/myforum/webroot 重定向到 404
我的论坛/.htaccess
DirectoryIndex index.php
# No directory listings
IndexIgnore *
<IfModule mod_rewrite.c>
RewriteEngine on
# Uncomment the following line if your webserver's URL is not directly related to physical file paths.
# Also uncomment it if you are on 1&1 hosting
#RewriteBase /
# Comment the following line if you have not a .well-known directory in the root folder.
RewriteRule ^(\.well-known/.*)$ $1 [L]
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
我的论坛/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
【问题讨论】: