【发布时间】:2015-12-10 13:07:29
【问题描述】:
在进行大量测试并深入研究 stackoverflow 之后,我无法弄清楚如何实现这一点。
我在子文件夹 (www.domain.com/subfolder/) 中有一个网站。我的 .htaccess 位于该子文件夹 (www.domain.com/subfolder/.htaccess) 中,并且我有 3 个 html (index.html, example1.html, example2.html)
我希望当您访问 www.domain.com/subfolder/example2.html 时,它会打开 www.domain.com/subfolder/example2/ 并使用干净的 url 并且 css、js 和图像路径正常工作。
我不知道如何将此子文件夹设置为 root 并继续使用干净的 url。
这是我实际的 .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.html
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
我尝试了几件事,但似乎没有任何效果。
提前致谢。 迭戈
【问题讨论】:
标签: .htaccess subdirectory clean-urls