seo配置

作者: zhenbinjing | 来源:发表于2019-04-02 10:05 被阅读0次

去除index.html或index.php等后缀文件

Nginx

在 .conf 配置文件中加以下代码

server

server

{

    listen 80;

    server_name  www.test.com;

    index index.html index.php index.htm;

  ...

}

Apache

找到apache的配置文件httpd.conf(文件在conf目录下)

打开httpd.conf,找到 #LoadModule rewrite_module modules/mod_rewrite.so 把#去掉

找到AllowOverride None 改成 AllowOverride All  

在.htaccess文件中加下面的代码

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.html/$1 [L]

留意:.htaccess文件前面有个点。

301重定向

Nginx

在 .conf 配置文件中加以下代码,意思就是用顶级域名指向 www 域名

server

{

    listen      80;

    server_name  test.com;

    return      301 http://www.test.com$request_uri;

}

server

{

    listen 80;

    server_name  www.test.com;

    index index.html index.php index.htm;

   ...

}

Apache

在.htaccess文件中加下面的代码,将不带 www 的域名转向到带 www 的域名下:

Options +FollowSymLinks

RewriteEngine On

RewriteCond %{http_host} ^test.com [NC]

RewriteRule ^(.*)$ http://www.test.com/$1 [L,R=301]

相关文章

网友评论

      本文标题:seo配置

      本文链接:https://www.haomeiwen.com/subject/ukcwbqtx.html