Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.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
Wordpress 将一条路径下的所有内容重定向到另一个域-nginx_Wordpress_Nginx - Fatal编程技术网

Wordpress 将一条路径下的所有内容重定向到另一个域-nginx

Wordpress 将一条路径下的所有内容重定向到另一个域-nginx,wordpress,nginx,Wordpress,Nginx,我对重写/重定向URL有问题 我的网站是website.com/news。。所有的文章都在哪里 我做了一个新网站articles.website.com,我想把/news下的所有链接重定向到articles.website.com上 例如: website.com/news/awesome-article在articles.website.com/awesome-article上重定向/重写。。使用nginx可以吗?多谢各位 我曾经 location ~ ^/news/(.*) {

我对重写/重定向URL有问题

我的网站是website.com/news。。所有的文章都在哪里

我做了一个新网站articles.website.com,我想把/news下的所有链接重定向到articles.website.com上

例如:

website.com/news/awesome-article在articles.website.com/awesome-article上重定向/重写。。使用nginx可以吗?多谢各位

我曾经

     location ~ ^/news/(.*) {
  return 301 http://www.articles.website.com/$1;
}
但它仍然在articles.website.com/news/awesome-article上进行新的url重定向。。但我要没有新闻的

我要重定向的网站的vhost(website.com)


对不起打扰了。我不知道为什么,但nginx不想接受这个重定向。晚上过后,我再次检查了这条规则,结果它成功了。

抱歉打扰了。我不知道为什么,但nginx不想接受这个重定向。晚上之后,我再次检查了这条规则,结果它成功了。

这段代码对我很有用。你能展示更多你的配置吗?“也许某个地方有冲突。”理查德史密斯当然,很抱歉没有添加冲突。它在主帖子中更新了。这个片段对我很有用。你能展示更多你的配置吗?“也许某个地方有冲突。”理查德史密斯当然,很抱歉没有添加冲突。在主要帖子中更新了它。
   server {
    listen   80; ## listen for ipv4; this line is default and implied

    root /var/www/vhosts/website.com;
    index index.html index.htm index.php;

    error_log /var/log/nginx/website.com.error.log;
    access_log /var/log/nginx/website.com.access.log;

    server_name dev.website.com website.com www.website.com;

    location / {
                try_files       $uri $uri/ /index.php?$args;
        }

#   location = /news {
  #return 301 http://articles.website.com$1;
#}

#   location = /news/ {
 # return 301 http://articles.website.com/$1;
#}

#   location = /news/wp-login.php {
 # return 301 http://articles.website.com/wp-login.php$1;
#}

      location ~ ^/news/(.*) {
return 301 http://articles.website.com/??$1;
}


    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

        # With php5-cgi alone:
        fastcgi_pass 127.0.0.1:9000;
        # With php5-fpm:
    #   fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #   deny all;
    #}
}