全球主机交流论坛

标题: 20元小红包!求一个 nginx301跳转代码, [打印本页]

作者: 分享吧    时间: 2015-2-24 17:01
标题: 20元小红包!求一个 nginx301跳转代码,
本帖最后由 分享吧 于 2015-2-24 17:55 编辑

http://xxxx.xx/xx.html   跳转到 http://xxx.xxxx.xx/xx.html

http://xxxx.xx/ab/xx.html   跳转到 http://xxx.xxxx.xx/ab/xx.html   其中ab是固定的



刚才没说明白抱歉,站是两个独立的站,

跳转的只要跳转以上那两条格式的就可以了。



已解决
  1. location / {
  2.         rewrite ^/([0-9].+).html$ http://xxx.xxx.xxx/$1.html last;
  3.         rewrite ^/category/([a-zA-Z].+)$ http://xxx.xxx.xxx/category/$1 last;
  4. }
复制代码



作者: adcen    时间: 2015-2-24 17:06
server_name  www.xxx.com xxx.com;
      if ($host != 'www.xxx.com') {
          rewrite ^/(.*)$ http://www.xx.com/$1 permanent;
      }
作者: adcen    时间: 2015-2-24 17:08
if ($http_referer ~* .*\.hostloc.com/1.HTML){
        return 301 http://loc.wget.at/B.HTML ;
      }

if ($http_referer ~* .*\.hostloc.com/2.HTML){
        return 301 http://loc.wget.at/2.HTML;
      }
作者: 分享吧    时间: 2015-2-24 17:13
adcen 发表于 2015-2-24 17:06
server_name  www.xxx.com xxx.com;
      if ($host != 'www.xxx.com') {
          rewrite ^/(.*)$ http ...

站的话,  是两个独立的站,

一个域名是 xxx.xx,另一个是二级域名  xx.xxx.xx。


作者: feixiang    时间: 2015-2-24 17:20
server_name  abc.com www.abc.com;
      if ($host != 'abc.com') {
          rewrite ^/(.*)$ http://321.123.com/$1 permanent;
      }


其实二楼写对了的吧,这么写楼主应该看懂了吧。
作者: 分享吧    时间: 2015-2-24 17:27
feixiang 发表于 2015-2-24 17:20
server_name  abc.com www.abc.com;
      if ($host != 'abc.com') {
          rewrite ^/(.*)$ http://3 ...

这应该是 判断 如果域名是 abc.com,就全部跳到 321.123.com吧

我想要的是, 只跳转  abc.com/*.html 和 abc.com/ab/*.html 。   需要保留abc.com/ac/*.html  这样。


作者: jiajieit    时间: 2015-2-24 17:35
我还有机会那那20红包么
作者: feixiang    时间: 2015-2-24 17:39
本帖最后由 feixiang 于 2015-2-24 17:46 编辑
  1. if ( $request_filename ~ ab/ )
  2.         {
  3.                 rewrite ^/(.*)$ http://321.123.com/$1 permanent;
  4.         }
复制代码


如果目录为 ab,跳转到 http://321.123.com 这个域名上


再或者:某个子目录作镜向

  1. location ^~ /ab
  2.         {
  3.                 rewrite ^.+ http://321.123.com/ last;
  4.                 break;
  5.         }
复制代码

作者: 分享吧    时间: 2015-2-24 17:45
feixiang 发表于 2015-2-24 17:39
如果目录为 ab,跳转到 http://321.123.com 这个域名上

PM我支付宝吧,虽然已经解决了,还是非常感谢。

  1. location / {
  2.         rewrite ^/([0-9].+).html$ http://old.sharebar.org/$1.html last;
  3.         rewrite ^/category/([a-zA-Z].+)$ http://old.sharebar.org/category/$1 last;
  4. }
复制代码

作者: feixiang    时间: 2015-2-24 17:46
分享吧 发表于 2015-2-24 17:45
PM我支付宝吧,虽然已经解决了,还是非常感谢。

不用哈,都是几个地球人,相互帮助应该的。
作者: 分享吧    时间: 2015-2-24 17:52
feixiang 发表于 2015-2-24 17:46
不用哈,都是几个地球人,相互帮助应该的。

那不行,  虽然钱不多,  一点 小小的心意..
作者: feixiang    时间: 2015-2-24 17:53
分享吧 发表于 2015-2-24 17:52
那不行,  虽然钱不多,  一点 小小的心意..

太客气了哈,过年过节的,心意领了,钱真不用哈。
作者: 分享吧    时间: 2015-2-24 17:54
feixiang 发表于 2015-2-24 17:53
太客气了哈,过年过节的,心意领了,钱真不用哈。

好吧,    谢谢。




欢迎光临 全球主机交流论坛 (https://loc.wget.at/) Powered by Discuz! X3.4