我尝试阅读许多有关 htaccess 的答案,但找不到出路。在 webhosting 中对该架构进行映像:root/public_html/subfolder 现在使用 htaccess 文件中的以下代码(放置在 public_html 中)我可以管理,当在浏览器中键入域时,访问者会进入没有数字 example.com/subfolder 的子文件夹,例如。 com就够了。有用。我现在想要的是,访问者不会被重定向到子文件夹中,而是在放置在根目录内的“额外文件夹”中(级别根目录与放置 public_html 文件夹但不在 public_html 内的同一级别)。那么如何修改这段代码:
# .htaccess main domain to subdirectory redirect
# Do not change this line.
RewriteEngine on
# Change example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subfolder/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subfolder/$1
# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ /subfolder/index.html [L]
我尝试用 ../extrafolder/ 更改 /subfolder/ (假设双点会向上推一级)但不起作用。任何想法?谢谢