【发布时间】:2026-01-10 21:00:01
【问题描述】:
我目前有一个文件夹结构
root/page1.html
root/page2.html
root/page3.html
root/page3/subpage1.html
并尝试使用重写规则在浏览器中显示时隐藏 .html 部分。
目前 .htaccess 看起来像:
#Alternate default index page
DirectoryIndex home.html
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule ^(.+?)/?$ $1.html [L]
我遇到的问题是,当我尝试单击一个链接时,该链接会将我带到 root/page3.html 它的 404ing,因为它试图重定向到 root/page3/.html
解决此问题的最佳方法是什么?我应该为此使用 .htaccess 还是更改我的结构?
【问题讨论】:
标签: html .htaccess directory-structure