I was working on a Svelte+Sapper application when I had the need to redirect to a page, with URL /spreadsheet/1
, when the user visited the root domain /
, instead of showing the home page.
当用户需要访问根域/
而不是显示主页时,我需要使用URL /spreadsheet/1
重定向到页面时,正在使用Svelte + Sapper应用程序。
So I opened src/routes/index.svelte
, removed everything in that file, and I added this code:
因此,我打开了src/routes/index.svelte
,删除了该文件中的所有内容,并添加了以下代码:
<script context="module">
export async function preload(page, session) {
return this.redirect(301, 'spreadsheet/1')
}
</script>