Redirect 将域重定向到Meteor中的另一个域
我有两个域名,一个我已经使用了很长时间(),另一个我现在正在使用的简化域名()。我使用托管,我的DNS设置为两个域都指向我的水滴,并且都正确显示在我的站点上 然而,我希望blainehansenpianostudio.com(更长、更烦人的一个)完全重定向到blainehansenpiano.com,但目前它只是一个别名,显示相同的站点,但也保留其令人烦恼的长url 关于http重定向,我能挖掘到的唯一东西是和这个。它们似乎都没有考虑到辅助域的存在,而是在使用应用内路由系统。这似乎不是正确的解决方案,因为重定向应该在包发送之前发生,对吗?我不希望在我的应用程序中发生大量无关的重定向 此外,SO问题有以下内容: 实现这一点的最简单方法是将重定向放在中间件中: 这对我来说没有任何意义。“中间件”在哪里 我怎样才能做到这一点呢?我觉得我需要更改服务器设置中的某些内容,但我部署了,其中没有提到任何有关重定向的内容,而且我甚至不确定我需要的服务器配置在哪里 提前谢谢 更新 我尝试将以下代码放入我的Redirect 将域重定向到Meteor中的另一个域,redirect,dns,meteor,Redirect,Dns,Meteor,我有两个域名,一个我已经使用了很长时间(),另一个我现在正在使用的简化域名()。我使用托管,我的DNS设置为两个域都指向我的水滴,并且都正确显示在我的站点上 然而,我希望blainehansenpianostudio.com(更长、更烦人的一个)完全重定向到blainehansenpiano.com,但目前它只是一个别名,显示相同的站点,但也保留其令人烦恼的长url 关于http重定向,我能挖掘到的唯一东西是和这个。它们似乎都没有考虑到辅助域的存在,而是在使用应用内路由系统。这似乎不是正确的解决
lib/router.js
文件中,只是为了测试一下,看看路由器是否是有问题的“中间件”:
WebApp.connectHandlers
.use(function(req, res, next) {
console.log(req);
console.log(res);
console.log(next);
next();
});
但事实并非如此。它把路由器弄坏了
可能的(但混乱的)解决方案
将此客户端重定向代码放入main.js
:
if (window.location.href.indexOf("blainehansenpianostudio") > -1) {
window.location = "http://blainehansenpiano.com";
}
可以,但在重定向完成后,它似乎会延迟一段时间。在我看来,这会触发两个完全独立的服务器请求,这一点都不理想。对于meteor应用程序,您可以使用javascript执行条件重定向。下面是一个例子:
<script type="text/javascript">
<!--
function Redirect() {
if(window.location.href.indexOf("blainehansenpianostudio") > -1){
window.location="http://blainehansenpiano.com";
}
}
//-->
</script>
在您的情况下,您可以选择将$scheme硬编码为http$请求uri部分确保重定向响应中包含原始请求uri
要设置nginx,我还建议使用@Steffo提供的链接。对于meteor应用程序,您可以使用javascript进行条件重定向。下面是一个例子:
<script type="text/javascript">
<!--
function Redirect() {
if(window.location.href.indexOf("blainehansenpianostudio") > -1){
window.location="http://blainehansenpiano.com";
}
}
//-->
</script>
在您的情况下,您可以选择将$scheme硬编码为http$请求uri部分确保重定向响应中包含原始请求uri
要设置nginx,我还建议使用@Steffo提供的链接。对于meteor应用程序,您可以使用javascript进行条件重定向。下面是一个例子:
<script type="text/javascript">
<!--
function Redirect() {
if(window.location.href.indexOf("blainehansenpianostudio") > -1){
window.location="http://blainehansenpiano.com";
}
}
//-->
</script>
在您的情况下,您可以选择将$scheme硬编码为http$请求uri部分确保重定向响应中包含原始请求uri
要设置nginx,我还建议使用@Steffo提供的链接。对于meteor应用程序,您可以使用javascript进行条件重定向。下面是一个例子:
<script type="text/javascript">
<!--
function Redirect() {
if(window.location.href.indexOf("blainehansenpianostudio") > -1){
window.location="http://blainehansenpiano.com";
}
}
//-->
</script>
在您的情况下,您可以选择将$scheme硬编码为http$请求uri部分确保重定向响应中包含原始请求uri
要设置nginx,我还建议使用@Steffo提供的链接我在
meteor
应用程序前面使用nginx
(也用于SSL终止-我看到您在站点上有一个登录
按钮,因此您可能需要SSL),它也在DO上运行。使用单个nginx实例接受两个域的请求,并将它们反向代理到单个meteor实例。我不会在meteor应用程序中使用重定向,因为这很容易干扰SSL设置
server {
listen 443 ssl;
server_name www.blainehansenpiano.com;
ssl_certificate /etc/ssl/blainehansenpiano.crt
(... SSL stuff )
location / {
proxy_pass http://meteor_localhost-OR-remotehost:3000;
(... some web socket setting ...)
}
}
以及指向同一流星实例的较长名称
server {
listen 443 ssl;
server_name www.blainehansenpianostudio.com;
ssl_certificate /etc/ssl/blainehansenpianostudio.crt
(... SSL stuff )
location / {
proxy_pass http://meteor_localhost-OR-remotehost:3000;
(... some web socket setting ...)
}
}
我在
meteor
应用程序前面使用nginx
(也用于SSL终止-我看到您在站点上有一个登录
按钮,因此您可能需要SSL),它也在DO上运行。使用单个nginx实例接受两个域的请求,并将它们反向代理到单个meteor实例。我不会在meteor应用程序中使用重定向,因为这很容易干扰SSL设置
server {
listen 443 ssl;
server_name www.blainehansenpiano.com;
ssl_certificate /etc/ssl/blainehansenpiano.crt
(... SSL stuff )
location / {
proxy_pass http://meteor_localhost-OR-remotehost:3000;
(... some web socket setting ...)
}
}
以及指向同一流星实例的较长名称
server {
listen 443 ssl;
server_name www.blainehansenpianostudio.com;
ssl_certificate /etc/ssl/blainehansenpianostudio.crt
(... SSL stuff )
location / {
proxy_pass http://meteor_localhost-OR-remotehost:3000;
(... some web socket setting ...)
}
}
我在
meteor
应用程序前面使用nginx
(也用于SSL终止-我看到您在站点上有一个登录
按钮,因此您可能需要SSL),它也在DO上运行。使用单个nginx实例接受两个域的请求,并将它们反向代理到单个meteor实例。我不会在meteor应用程序中使用重定向,因为这很容易干扰SSL设置
server {
listen 443 ssl;
server_name www.blainehansenpiano.com;
ssl_certificate /etc/ssl/blainehansenpiano.crt
(... SSL stuff )
location / {
proxy_pass http://meteor_localhost-OR-remotehost:3000;
(... some web socket setting ...)
}
}
以及指向同一流星实例的较长名称
server {
listen 443 ssl;
server_name www.blainehansenpianostudio.com;
ssl_certificate /etc/ssl/blainehansenpianostudio.crt
(... SSL stuff )
location / {
proxy_pass http://meteor_localhost-OR-remotehost:3000;
(... some web socket setting ...)
}
}
我在
meteor
应用程序前面使用nginx
(也用于SSL终止-我看到您在站点上有一个登录
按钮,因此您可能需要SSL),它也在DO上运行。使用单个nginx实例接受两个域的请求,并将它们反向代理到单个meteor实例。我不会在meteor应用程序中使用重定向,因为这很容易干扰SSL设置
server {
listen 443 ssl;
server_name www.blainehansenpiano.com;
ssl_certificate /etc/ssl/blainehansenpiano.crt
(... SSL stuff )
location / {
proxy_pass http://meteor_localhost-OR-remotehost:3000;
(... some web socket setting ...)
}
}
以及指向同一流星实例的较长名称
server {
listen 443 ssl;
server_name www.blainehansenpianostudio.com;
ssl_certificate /etc/ssl/blainehansenpianostudio.crt
(... SSL stuff )
location / {
proxy_pass http://meteor_localhost-OR-remotehost:3000;
(... some web socket setting ...)
}
}
如何设置alias?你可以在那个地址设置一个简单的页面来重定向。访问这两个链接,你会看到它们都显示相同的实际站点,但它们保留各自的URL。这就是我所说的“别名”。也许我没有恰当地使用这个词。作为对使用维基百科文章中的一种技术的回应,我想我是在问如何在我的特定设置中这样做。Meteor几乎完全为您处理服务器端,在“blainehansenpianostudio.com”上创建另一个刚刚重定向的页面可能需要我使用Digital Ocean设置另一个droplet,这将是一种浪费