I want to stop this from happening https://www.site.com/articles/abc This should be redirected (to remove www) as in my server block configuration. I don’t understand why however. I have looked a lot at similar solutions on server fault and wonder if there is something more specific for DO.
here is the config thank you for help.
server {
listen 80;
listen [::]:80;
server_name site.com www.site.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl http2;
include snippets/ssl-site.com.conf;
include snippets/ssl-params.conf;
root /var/www/site.com/html;
index index.html index.htm index.nginx-debian.html index.php;
server_name site.com www.site.com;
#rewrite ^ https://site.com$request_uri? permanent;
#return 301 https://$server_name$request_uri;
add_header X-Frame-Options "SAMEORIGIN";
rewrite ^(.*)/(\d+)-([^/]+)(.*)$ $1/$3 permanent;
rewrite ^.*\.(pptx)$ https://caribbean-diving.com permanent;
location ~* \.(?:css|js|gif|jpeg|jpg|png)$ {
expires max;
add_header Cache-Control public;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ /.well-known {
allow all;
}
}
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
This question was answered by @landed:
View the original comment