2016-03-23 18 views
0

Yeniden yazma/yönlendirme URL'leriyle ilgili bir sorunum var.Her yolu tek bir yol altında başka bir etki alanına yönlendir - nginx

Sitede/website var.

Yeni site articles.website.com sitesi yaptım ve articles.website.com adresinde yeniden yönlendirmek için tüm bağlantıları/haberleri yeniden yönlendirmek istiyorum. Yani örnekteki

:

website.com/news/awesome-article yönlendirme/articles.website.com/awesome-article .. üzerinde yeniden nginx ile mümkün olabilir? Teşekkür ederim.

Hala articles.website.com/news/awesome-article yeni url yönlendirme üzerinde
 location ~ ^/news/(.*) { 
    return 301 http://www.articles.website.com/$1; 
} 

Ama o `kullanılan .. ama/haber withnout istiyorum. site için

Benim sankonun ben rahatsız için (website.com)

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; 
    #} 
} 
+0

Snippet benim için çalışıyor. Yapılandırmanızın daha fazlasını gösterebilir misiniz? Belki bir yerde bir çatışma var. –

+0

@RichardSmith offcourse, eklemediğiniz için üzgünüm. Onun ana postada güncellendi. – Delirium

cevap

0

Maalesef yönlendirmek istiyorum. Nedenini bilmiyorum ama nginx bu yönlendirmeyi kabul etmek istemedi. Gece sonra, o kuralı iki kez kontrol ederim ve bu da wokrs.

İlgili konular