【发布时间】:2016-05-10 01:36:12
【问题描述】:
我有一些 index.html 文件放在一个文件夹中以获取一些不错的 url -
site.com/about
index.html 位于 about 文件夹中。但是我看到我的 site.com/about 被 301 重定向到 site.com/about/ 我不确定 301 是从哪里生成的。它不在配置中。
/about/ 也有 301 结果。
我想这是有道理的,因为我正在重定向到 index.html 文件,但它不应该是重写吗?有没有办法为 /about 返回 200 而不是 301 到 about/?
我正在使用 Nginx
服务器块:
server {
listen IP;
server_name site.com;
rewrite / $scheme://www.$host$request_uri permanent;
}
server {
listen IP:80;
server_name site.com *.site.com;
root /var/www/vhosts/site.com/htdocs;
charset utf-8;
rewrite_log on;
location / {
index index.html index.php;
try_files $uri $uri/ /$uri.php;
expires 30d;
}
if ($request_uri = /index.php) {
return 301 $scheme://$host;
}
if ($request_uri = /index) {
return 301 $scheme://$host;
}
location /. {
return 404;
}
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}
include "ssl_offloading.inc";
location ~ .php$ {
# if (!-e $request_filename) { rewrite / /index.php last; }
if (!-e $request_filename) { rewrite / /404.php last; }
}
}
【问题讨论】:
-
请分享您的服务器块的内容。解决方法很简单,但我更愿意给出具体建议。
-
我投票结束这个问题,因为它属于the site for Professional Wemasters
-
这是一个配置编程问题而不是 SEO 问题
标签: nginx seo http-status-code-301