Articles of redirect

将HTTPS网站迁移到单个IP上的另一个域名

我使用HTTPS协议(nginx webserver)运行一个网站。 现在我想将其迁移到一个新的域名。 我在使用HTTP的时候多次做了这个。 但是,使用HTTPS将会有所不同,因为应该为新的域名提供不同的证书。 提前了解并避免什么隐患? 什么是尽可能平稳过渡移民的最佳途径?

Nginxconfiguration不断抛出一个redirect循环,同时试图将wwwredirect到非www和https

我正尝试将所有www请求redirect到我的网域,而不是wwwurl,并且所有内容都是https 。 这是我的nginxconfiguration: server { listen 80; server_name example.com www.example.com; location '/.well-known' { default_type "text/plain"; root /home/letsencrypt; allow all; } return 301 https://example.com$request_uri; } server { listen 443 ssl http2; server_name www.example.com; include snippets/ssl-example.com.conf; include snippets/ssl-params.conf; location '/.well-known' { default_type "text/plain"; root /home/letsencrypt; allow all; } return 301 https://example.com$request_uri; } server { listen 443 ssl […]

在nginx上,node.js https / wwwredirect到https非www

我使用nginx作为我的node.js应用程序。 我已经使用Digitalocean教程来configurationnginx和https的使用。 现在,下面的工作: http:// example.com – > https:// example.com example.com – > https:// example.com www.example.com – > https:// example.com http:// www.example.com – > https:// example.com 但是当我inputhttps:// www.example.com时,它不会redirect到https:// example.com 这里是我的nginx congif网站,可用/默认 # HTTP – redirect all requests to HTTPS: server { listen 80; listen [::]:80 default_server ipv6only=on; return 301 https://$host$request_uri; } # HTTPS – proxy requests […]

htaccessredirect到特定域的所有stream量到另一个域,排除文件夹和文件types

指向相同cPanel帐户的多个别名域共享相同的.htaccess文件。 只有在以下情况下,我需要一个特定于域的规则,将所有来自aliasdomain.comstream量redirect到https://www.domain1.com 。 HTTP_HOST目前是aliasdomain.com (有或没有WWW和http / https) 排除文件夹/medias/ – 它仍然可以从aliasdomain.com访问 排除所有*.jpg , *.jpeg , *.png和*.gif文件(即使文件位于aliasdomain.com根目录中) 总是redirect到https://www.domain1.com root,没有通配符redirect,也没有redirect到非ssl http domain1.com需要被排除,所以如果相同的.htaccess文件是在domain1.com它不会干涉。 我试图适应在StackOverflow上find的各种代码片段,但失败了可怕得到它的工作:(我问了一个问题,但MODS告诉我要问ServerFault,所以我在这里…帮助将非常感激!

设置DNSlogging始终parsing到裸体域(没有www)

我使用Enom.com的DNS服务器来pipe理多个域的DNS设置。 我无法理解如何正确设置DNS,以便所有http请求都能parsing为裸域,而不会导致example.com redirected you too many times错误。 所以,不pipe以下任何一项: http://www.example.com http://foo.example.com http://*.example.com DNSlogging应该总是redirect到http://example.com的裸域 IIS服务器(Windows 2016) 此外,我不希望为每个域设置一个具有规范域名规则的IIS URL重写。 我的首选是使DNSlogging简单地将所有事情都解决回裸域。 IIS主机logging 我的服务器在很大程度上依赖主机头logging来正确地parsing传入的请求到正确的网站。 换句话说,几个域的Alogging指向我的服务器上的同一个IP地址。 当前的DNSloggingconfiguration(使用Enom) Host Name Record Type Address www URL Redirect example.com @ (none) A (Address) 1.2.3.4 * (all others) URL Redirect example.com URLredirectlogging是Enom提供的特殊logging。 从Enom Host Records帮助页面 : URLredirect不是本地DNSloggingtypes。 为主机名指定URLredirect会创build一个将名称指向我们的URL转发服务器的基础Alogging。 这些服务器然后执行HTTP 301redirect到您在地址字段中指定的URL。 您只能指定要转到的域名,或指定特定文件的完整path。 问题摘要 如何设置DNSlogging,以便域的所有变体始终发送到裸域而不必使用IIS URL重写规则?

Nginx:将.php请求redirect到无扩展版本

我有以下configuration,现在将/create_user/check重写为/create_user.php?check=true 。 location / { try_files $uri $uri/ @ext-php; } location @ext-php { rewrite ^(.*)/create_user/check$ $1/create_user.php?check=true last; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } 另外,我想将使用“create_user.php?check = true”版本的用户redirect到无扩展版本。 什么是最好的方式来configuration? 是在服务器块(如下)重写一个好办法做到这一点? rewrite ^(.*)/create_user.php?check=true$ $1/create_user/check redirect; 更新:以下configuration更改工作:添加一个地图块: map $query_string $updated_path { "check=true" "check"; } 并将服务器块中的重写更改为: rewrite ^(.*/create_user).php$ $1/$updated_path? redirect;

如何让nginx返回404,除非请求一个特定的域名?

我有一个nginx服务器,我想返回404时,请求anything除了anything是www , mypythonapp1或mypythonapp2 我在/etc/nginx/sites-enabled创build了一个00-noredirect文件: server { listen 80; listen 443 ssl; server_name _; return 404; } 不幸的是,一切都redirect到mypythonapp1 。 其他服务器块如下: server { listen mypythonapp1.mydomain.com:80; server_name mypythonapp1.mydomain.com; (…) listen mypythonapp1.mydomain.com:443 ssl; # managed by Certbot (…) } 我认为这可能与我/etc/nginx/sites-enabled/mypythonapp1 ,即使我不确定: (…) if ($scheme != "https") { return 301 https://$host$request_uri; } # managed by Certbot (…) 有什么我必须添加到00-noredirect避免这种不需​​要的行为? 编辑:按照@Tim的要求,这里是我的 – […]

代理(或redirect?)每个位置的请求

像这样的东西可以在mod_proxy中全局运行: ProxyPass /api/* http://localhost:8081/api ProxyPassReverse /api/* http://localhost:8081/api 所以我所有的/api客户端请求都被定向到http://localhost:8081/api 如果我有两个位置,如localhost/site1/ localhost/site2/ ,我需要不同的redirect每个站点?所有这些应用程序请求/ apiasynchronous 所以访问site1,xhr调用请求/ api,我想要http:// localhost:8081 / api来响应 for / site2一个xhr调用请求/ api,我想要http:// localhost:9091 / api来响应 这可以通过在每个文件夹中的.htaccess来完成,或者通过全局redirect来完成吗?我需要mod_rewrite和http Referrer规则或mod_proxy这个吗? 谢谢

redirect从www到nginx反向代理中没有www

我正在用nginx反向代理和gunicorn应用程序服务器开发一个Django应用程序。 作为一个新手的Web开发人员,我需要帮助redirect到no www服务器级别的wwwstream量。 我目前在应用程序中的中间件级别做同样的事情,但需要提高性能。 目前我的nginx虚拟主机文件的布局如下: proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my_cache:10m max_size=100m inactive=6m; upstream my_server { server unix:/home/myuser/myproject/myfolder/myproject.sock fail_timeout=0; } server { listen 80; server_name example.com www.example.com; # a bunch of 'location' blocks eg 'location /' or 'location @http_proxy_to_app', etc. } server { listen 443 ssl; server_name example.com www.example.com; # SSL related stuff # a bunch of […]

作为reverse_proxy在nginx中从HTTPSredirect到HTTP

我有一个边缘服务器,其中安装了清漆和Nginx。 我使用Nginx作为用于HTTPSstream量的SSL终止的reverse_proxy,并且还转发HTTPstream量。 两个交通都被转移到清漆。 我有几个HTTP和HTTPS网站与有效的SSL正常工作。 我有一个网站有很多停放的域名不在HTTPS。 但是,当我在Google中search其中的一个链接时,该页面以HTTPS显示,浏览器尝试以HTTPS打开它,所以我得到HTTPS错误! 我也没有创build任何虚拟主机块在Nginx的该域! 我想知道有什么方法可以将非https网站redirect到其http版本,或者更通常地将所有具有无效SSL的网站redirect到它们的HTTP版本? 如果能做到的话,是否应该用清漆来改变?