我有一个URL,其中Hugo的静态生成站点为:
www.myurl.com/blog
例如,以类似的方式访问来自Hugo的index.md/index.html
www.myurl.com/blog/index.html
现在,我需要htaccess来将URL重写为:
www.myurl.com/index.html
我该怎么做?
与此同时,我尝试了
RewriteCond %{REQUEST_URI} !^/blog/
RewriteRule ^(.*)$ /blog/$1 [L,QSA]
它可以工作,但不完全像我想要的那样。因为如果我在www.myurl.com/somwhere/really/deep/detail.html中的博客文章中链接了某些内容,它将无法工作,因为它会重定向到/ blog /。有什么办法解决这个问题?
答案 0 :(得分:0)
您的RewriteRule会将所有/ blog /网址都重定向到博客。但是您可以过滤出要从此规则中排除的所有目录:
RewriteCond %{REQUEST_URI} !^/blog/
RewriteCond %{REQUEST_URI} !^/somewhere
RewriteCond %{REQUEST_URI} !^/somewhere2
RewriteRule ^(.*)$ /blog/$1 [L,QSA]