Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Redirect 在Middleman中,重定向到my config.rb中的临时主页不起作用_Redirect_Middleman - Fatal编程技术网

Redirect 在Middleman中,重定向到my 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

最初在我的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
重定向到
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/临时主页

您是否缺少尝试重定向到的页面的文件扩展名?不要在第一个字符串中添加开始斜杠。还要将文件扩展名添加到重定向路径。