Redirect 在Middleman中,重定向到my config.rb中的临时主页不起作用
最初在我的config.rb中,我有以下内容:Redirect 在Middleman中,重定向到my config.rb中的临时主页不起作用,redirect,middleman,Redirect,Middleman,最初在我的config.rb中,我有以下内容: activate :i18n, mount_at_root: false, langs: ['en-us', 'es-mx'] activate :directory_indexes redirect 'index.html', to: 'en-us' 这非常适合将localhost:4567/重定向到localhost:4567/en-us。但是,我实际上想将localhost:4567/和localhost:4567/en-us重定向到lo
activate :i18n, mount_at_root: false, langs: ['en-us', 'es-mx']
activate :directory_indexes
redirect 'index.html', to: 'en-us'
这非常适合将localhost:4567/
重定向到localhost:4567/en-us
。但是,我实际上想将localhost:4567/
和localhost:4567/en-us
重定向到localhost:4567/en-us/临时主页
在config.rb中更改我以前的重定向可以正常工作:
redirect 'index.html', to: "en-us/temporary-home-page"
当我尝试为localhost:4567/en-us
添加重定向时,它不起作用:
redirect 'en-us/index.html', to: "en-us/temporary-home-page"
我仍然在localhost:4567/en-us
上结束。我还尝试了以下每种组合,结果相同:
redirect 'en-us', to: "en-us/temporary-home-page"
redirect 'en-us/', to: "en-us/temporary-home-page"
redirect 'en-us/index.html', to: "en-us/temporary-home-page"
redirect '/en-us', to: "en-us/temporary-home-page"
redirect '/en-us/', to: "en-us/temporary-home-page"
redirect '/en-us/index.html', to: "en-us/temporary-home-page"
在某些情况下,它会在浏览器中输出:
<html>
<head>
<link rel="canonical" href="en-us/temporary-home-page" />
<meta http-equiv=refresh content="0; url=en-us/temporary-home-page" />
<meta name="robots" content="noindex,follow" />
<meta http-equiv="cache-control" content="no-cache" />
</head>
<body>
</body>
</html>
我错过了什么?如何使/
、/en-us
和/en-us/
URL重定向到/en-us/临时主页
?您是否缺少尝试重定向到的页面的文件扩展名?不要在第一个字符串中添加开始斜杠。还要将文件扩展名添加到重定向路径。