Ubuntu服务器SEO配置技巧
一 基础架构与域名规范
sudo apt install certbot python3-certbot-nginx && sudo certbot --nginx -d yourdomain.com;Apache 使用 certbot:sudo apt install certbot python3-certbot-apache && sudo certbot --apache -d yourdomain.com。abc.com 的 80/443 分别 301 到 https://www.abc.com。Sitemap: https://yourdomain.com/sitemap.xml。二 Nginx与Apache的SEO友好配置
gzip on; keepalive_timeout 65;location ~* \.(jpg|jpeg|png|webp|gif|ico|css|js)$ { expires 1y; add_header Cache-Control "public, immutable"; }add_header X-Frame-Options DENY; add_header X-Content-Type-Options nosniff;index.html 并配合前端 history 模式。sudo a2enmod rewrite ssl headers expires deflate cache cache_disk<Directory /var/www/your-site/public_html> 中设置 AllowOverride All 以启用 .htaccess 重写。/article/123/my-title 重写为 article.php?id=123&title=my-titleRewriteEngine On
RewriteBase /
RewriteRule ^article/([0-9]+)/([a-zA-Z0-9-]+)$ article.php?id=$1&title=$2 [L,QSA]
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html "access plus 1 week"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
</IfModule>
三 性能与安全基线
htop、fail2ban、日志轮转);记录关键指标(TTFB、首屏、可用性)并持续优化。四 内容与技术SEO清单
五 快速检查与监控
https://yourdomain.com/sitemap.xml 与 robots.txt 是否可访问;curl -I 检查 301/302 与 HSTS 头;Content-Encoding: gzip、Cache-Control);