【发布时间】:2019-02-06 19:59:34
【问题描述】:
我在domain.com 有一个站点,我想在blog 子目录中添加子站点。
在子目录的domain.com/blog/index.html 文件中,我尝试使用post-1、/post-1 和./post-1 链接到单个帖子。
预期的 URL 是 domain.com/blog/post-1,但是链接上的 URL 是 domain.com/post-1。
.htaccess 能否将子目录的 baseUrl 更新为domain.com/blog/?这意味着blog 目录中的所有relative url 都将是domain.com/blog/[some-url-here]。
我试过了,但它不正确:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.html$ / [R=301,L]
RewriteRule ^blog/(.*)/index\.html$ /$1/ [R=301,L]
</IfModule>
感谢您的帮助。
【问题讨论】:
标签: .htaccess mod-rewrite url-rewriting apache2 subdirectory