私はリライト/リダイレクトURLに問題があります。あるパスのすべてを別のドメインにリダイレクトします - nginx
私はサイトwebsite/newsを持っていました.. in/newsはすべて記事です。
新しいサイトarticles.website.comを作成しました。記事の下にあるすべてのリンクをnews.website.comにリダイレクトしたいと思います。例中のSO
:
website.com/news/awesome-article articles.website.com/awesome-articleに書き換え/リダイレクト...は、nginxの持つ可能ということでしょうか?ありがとうございました。
私は
location ~ ^/news/(.*) {
return 301 http://www.articles.website.com/$1;
}
を使用しかし、それ `sまだarticles.website.com/news/awesome-articleに新しいURLリダイレクション上..しかし、私はそれwithnout /ニュースたいです。悩ませて申し訳ありません
私は(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;
#}
}
スニペットは私に役立ちます。より多くの設定を表示できますか?たぶんどこかに紛争があるかもしれない。 –
@RichardSmith offcourse、申し訳ありませんが、追加していません。メインポストで更新されました。 – Delirium