Articles of redirect

Nginx + WordPress语言redirect

我目前正在尝试使用用于语言支持的Wordpress多站点来configurationNginx安装。 多站点configuration:mysite.com(未使用)mysite.com/it mysite.com/en 基本上我想添加一个默认的语言和redirect,如果我find英语。 该网站实际上是在Apache安装,所以我们使用: RewriteCond %{HTTP:Accept-Language} ^en [NC] RewriteRule ^$ /en/ [L,R=301] RewriteRule ^$ /it/ [L,R=301] 为实际的redirect。 我试图用nginx复制,没有任何运气。 到目前为止我补充说: map $http_accept_language $lang { default it; ~en en; } server { listen 80; server_name mysite.com; access_log /var/log/nginx/logs/mysite-access.log ; error_log /var/log/nginx/logs/mysite-error.log ; location / { root /var/www/html/mysite; index index.php index.html; try_files $uri $uri/ /index.php?$args; rewrite ^ […]

将旧域的子域redirect到新域中的目录

我想将旧域的子域redirect到新域的目录。 例如forum.old-domain.com应该redirect到new-domain.com/forum从old-domain.comredirect到www.new-domain.com正在工作,除了子域。 htaccess看起来像这样: Options +FollowSymlinks RewriteEngine on rewritecond %{http_host} ^forum\.old-domain\.de [nc] rewriterule ^(.*)$ http://www.new-domain.de/forum/$1 [r=301,nc,l] rewritecond %{http_host} !^www.new-domain.de [nc] rewriterule ^(.*)$ http://www.new-domain.de/$1 [r=301,nc,l] # rewritecond %{http_host} ^forum.old-domain.de [nc] # rewriterule ^(.*)$ http://www.new-domain.de/forum/$1 [r=301,nc,l] rewritecond %{http_host} ^old-domain.de [nc] rewriterule ^(.*)$ http://www.new-domain.de/$1 [r=301,nc,l] rewritecond %{http_host} ^www.old-domain.de [nc] rewriterule ^(.*)$ http://www.new-domain.de/$1 [r=301,nc,l] 问题是,forum.old-domain.comredirect到www.new-domain.com,但我希望它redirect到www.new-domain.com/forum。 有什么build议么? 我错过了什么? 提前致谢! 编辑: 添加虚拟主机条目: […]

添加一个URL后缀path(移动AMP),而不会在nginx中导致redirect循环

我正在使用nginx web服务器为我的wordpress网站。 我将使它成为移动服务的放大版本。 我想添加/放大/我的url。 我也使用漂亮的固定链接为我目前的url,所以我可以知道如何重写我的url在手机版/放大器/ 我正在使用重写^ http://example.com $ request_uri / amp / break; 但是当我服务networking时,它变成了这个 exmaple.com/homepage//amp//amp//amp//amp//amp//amp//amp//amp//amp//amp//amp//amp//amp//amp//amp//amp//amp//amp//amp//amp//amp/ 我希望当iphone服务的网页,链接将是http://exmaple.com/homepage/amp/ 主要目的我只想添加/放大/网站的任何链接。 这是我的nginx.conf server { listen 80; server_name example.com; charset utf-8; access_log logs/xxx.access.log; root /var/www/html; index index.php; location / { try_files $uri $uri/ /index.php?q=$uri; } location /en { try_files $uri $uri/ /en/index.php?q=$uri; } location /my { try_files $uri $uri/ /my/index.php?q=$uri; […]

redirectIIS与多个域

在IIS7中,有一条规则可以自动redirect到我们网站使用的HTTPS。 <rule name="Redirect to HTTPS" enabled="true" stopProcessing="false"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="^OFF$" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" /> </rule> 我们正在使用相同的Web应用程序添加一个新的域名(例如www.newdomain.com),但是URL的处理方式不同。 当在newdomain.com或类似地www.newdomain.com上访问时,用户应该被redirect到https://www.newdomain.com/example ,因为我们目前没有为newdomain.com提供SSL证书。 然而,我们现有的域使用一个单独的子域名比我们不需要由IIS处理。 要处理这个redirect,我使用下面的规则: <rule name="Redirect newdomain" enabled="true" stopProcessing="false"> <match url="(^$)" /> <conditions> <add input="{HTTP_HOST}" pattern="^(www\.)?newdomain\.com$" /> </conditions> <action type="Redirect" url="https://www.newdomain.com/example" appendQueryString="true" redirectType="Permanent" /> </rule> 从www.newdomain.com访问该网站时,此规则有效。 但是,当尝试访问没有子域名的newdomain.com时,redirect仅出现在初始规则中,并且用户被定向到https://newdomain.com ,并出现ssl证书错误。 如何获得redirect来设置正确的子域,而不影响任何网站只使用其他规则?

Apache 2.4 mod_rewrite规则应用redirect到非redirect规则(只有标志)

所以我有这个疯狂的问题发生在apache 2.4 / CentOS7上的一个web应用程序。 我想redirect应用程序域上的所有非安全的URL到安全版本,除了一个uri(供应商沙箱模式的webhook端点 – 没有有效的SSL证书,因为这不是生产,所以我们必须允许http)。 除了应用程序域之外,还有一些客户站点域也贯穿于此,所以我们不希望那些redirect,因为没有SSL,所以我们明确地匹配HTTP_HOST。 这是一个前端控制器模式,我们希望index.php将所有这些请求处理到所有域的非文件和非目录,以及仅通过应用程序域的SSL。 它很简单: RewriteEngine on RewriteBase "/" # Redirect all app domain urls to ssl RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} "^app\.example\.com$" [NC] RewriteCond %{REQUEST_URI} "!^/AllowThisUri/Http" RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # I had to split this -d rule off of the -f rule to account for custom # domain […]

为一个IP地址托pipe的两个基于名称的网站之一禁用HTTPS

我有一个本地Apache2服务器,在一个IP上托pipe两个基于名字的网站。 第一个网站仅托pipe在端口80上。第二个网站托pipe在端口80和443上。如果在端口80上访问,用户将redirect到端口443。 one.local(仅限HTTP): <VirtualHost *:80> ServerName one.local ServerAlias www.one.local DocumentRoot /var/www/html/one </VirtualHost> two.local(http和https): <VirtualHost *:80> DocumentRoot /var/www/html/two ServerName two.local ServerAlias www.two.local Redirect permanent / https://two.local </VirtualHost> <VirtualHost *:443> DocumentRoot /var/www/html/two ServerName two.local ServerAlias www.two.local SSLEngine on SSLCertificateFile /etc/apache2/ssl/apache.pem SSLCertificateKeyFile /etc/apache2/ssl/apache.key </VirtualHost> 这两个网站都可以访问,使用域名和two.local获得redirect就好了。 我遇到的问题是,当访问https://one.local ,用户已连接并提示Your connection is not secure因为尝试使用two.local的自签名证书。 我已经阅读了这个问题,似乎解决scheme是再次使用相同的证书,并从httpsredirect到http。 这个问题已经在三年前问过了,这个问题有没有更好的解决办法呢?

避免双重redirectNGINX

我正在使用301redirect到Nginx,将我的网站用户redirect到网站的HTTPS版本。 我使用Google的PageSpeedtesting了我的网站,发现我是从主页面redirect的。 这是因为我的CMS。 例: http:// domain.tld – > NGINX 301 – > https:// domain.tld – > CMSredirect – > https:// domain.tld / homepage 我希望能用NGINXredirect直接根连接 location = / { return 301 https:// domain.tld/homepage; } 这适用于主页,但是,这将给404任何其他http页面的错误比主页,我试图添加return 301 https://$host$request_uri; 在位置块,但不知何故这覆盖了根域的规则。 (这再次提供了一个双redirect)有没有办法redirect所有链接与他们相应的request_uri,除了根域? PS我希望没有iffunction做到这一点:请参阅: https : //www.nginx.com/resources/wiki/start/topics/depth/ifisevil/ 这里是我的完整configuration文件的示例: server { listen 80; server_name domainname.tld; location = / { return 301 […]

尝试将HTTPredirect到nginx中的HTTPS作为jenkins的反向代理时,从服务器返回空回复

我正在Jenkins后面运行Jenkins,并使用Let's Encrypt来获得SSL证书。 如果我通过https://jenkins.mydomain.de/访问该网站,一切工作正常。 但是,当我通过http://jenkins.mydomain.de/访问它,Firefox说:“连接被重置。”和curl说:“从服务器的空回复” 我如何debugging? 我真的不知道该在哪里寻找问题。 nginx日志不包含任何关于它的事情。 我怀疑在下面的configuration中关于端口80的部分是由其他指令无效,但我不知道我将如何调查。 $ curl -svL http://jenkins.mydomain.de/ * Hostname was NOT found in DNS cache * Trying my.ip.add.ress… * Connected to jenkins.mydomain.de (my.ip.add.ress) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.38.0 > Host: jenkins.mydomain.de > Accept: */* > * Empty reply from server * Connection #0 to host […]

.htaccessredirect问题

这是我需要做的。 将sub1.domain1.co.ukredirect到sub2.domain2.com 将sub2.domain2.comredirect到sub2.domain2.com/sub-folder 这两个工作,但这不: 直接导航到sub1.domain1.co.uk/sub-folder不会redirect到sub2.domain2.com/sub-folder 。 这是我的redirect: RedirectMatch ^/$ http://sub2.domain2.com/sub-folder RewriteCond %{HTTP_HOST} ^sub1.domain1.co.uk$ [NC] RewriteRule (.*) sub2.domain2.com/$1 [R=301,L]

nginxredirect没有端口

我有一个Nginx的301redirect问题。 它总是通过本地端口redirect到一个URL。 情况如下:网站正在运行Cloudflare,完整的https。 CF将http请求发送到varnish接受它们的服务器。 清漆然后将请求传递给nginx,它与FPM一起处理其余部分。 Nginx运行在8080端口。我在Nginx中创build一个301redirect,就像我通常做的那样: location = /url1 { return 301 /url2; } Nginx然后redirect到URL,但是添加它运行的原始主机名和端口(8080)。 所以我将port_in_redirect设置为在服务器configuration中closures。 那工作一半。 它会将一个http URLredirect到https(不提到端口8080)。 它会redirect一个https URL到http,虽然,循环。 我怎样才能确保这不会发生? 我想知道是否有可能知道Cloudflare也在为请求提供服务。