/DEx.html/SEO amaçları için yeniden yazmak/(yinelenen içerik için index.html ile karıştırılan ve yinelenen içerik için ceza alan aptal arama motorları) - ayrıca web analizi verilerini uzlaştırmak için .nginx /index.html için/rewrite
Stackoverflow, nginx belgeleri vb. Üzerinde bulduğum her çözümü denedim ve hiç başarı elde edemedim. Sanırım başka bir yapılandırma sorunum veya acı bir şekilde açık bir şey olmalı. Bu benim ilk nginx kurulumudur - Apache ve IIS için kullanılır! İşte
benim default.conf: İşteserver {
listen 80;
server_name web.local;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
benim virtual.conf olan (bölüm benim en son girişimdi dışarı yorumladı - uncommented zaman bir 301 www erişmeye çalıştığınızda hata Kalıcı Olarak Taşındı verir .domain.com/index.html):
server {
listen 80;
server_name www.domain.com;
location/{
root /var/www/html/domain.com;
index index.html;
#if ($request_uri = /index.html) {
# rewrite^http://www.domain.com permanent;
#}
}
}
server {
listen 80;
server_name domain.com;
rewrite ^/(.*) http://www.domain.com/$1 permanent;
}
HTTP Cevap cobaco en çözümü için:
URL:
http://www.domain.com
http/1.1 301 moved permanently
server: nginx/1.2.8
date: Thu, 16 May 2013 01:42:58 GMT
content-type: text/html
content-length: 184
connection: keep-alive
location: http://domain.com/
Redirecting URL:
http://domain.com/
http/1.1 301 moved permanently
server: nginx/1.2.8
date: Thu, 16 May 2013 01:42:58 GMT
content-type: text/html
content-length: 184
connection: keep-alive
location: http://www.domain.com/
Bu satırın sorunlara neden olabileceğini düşündüm: "location = /index.html {return 301 $ scheme: //domain.com/;}" böylece www ekledim. "scheme: //" ifadesinden sonra - bunun yapılabilecek kötü bir şey olup olmadığını bana bildirin! Bu şu HTTP Cevap Başlıklarındaki sonuçlandı: Biraz daha müdahalesi sonrasında
URL:
http://www.domain.com
http/1.1 301 moved permanently
server: nginx/1.2.8
date: Thu, 16 May 2013 01:42:58 GMT
content-type: text/html
content-length: 184
connection: keep-alive
location: http://www.domain.com/
Redirecting URL:
http://www.domain.com/
http/1.1 301 moved permanently
server: nginx/1.2.8
date: Thu, 16 May 2013 01:42:58 GMT
content-type: text/html
content-length: 184
connection: keep-alive
location: http://www.domain.com/
, aşağıdaki yapılandırma bunu yapmak istiyorum fakat eğer açıklamaya ideal değildir yapar. Baska öneri? Eğer sonra bazı bukle uygulaması yazıyorsanız
server {
server_name www.domain.com;
root /var/www/html/domain.com;
index index.html;
if ($request_uri = /index.html) {
return 301 http://www.domain.com/;
}
#location = /index.html {
# return 301 $scheme://www.domain.com/;
#}
}
server {
listen 80;
server_name domain.com;
return 301 $scheme://www.domain.com$request_uri;
}
teşekkürler, iyi çalışıyor! :) – auralsun