简单粗暴的去除 WordPress 去除 url 中的 index.html|去掉链接中的 index.php 其实方式方法很多。下面这种方法是最简单,也是对

SEO 影响最小的一种方式,把 index.html 或者 index.php 301 重定向到主域名即可。

如果是独立服务器或者是 VPS 非常好办。

Nginx 下的解决方法:

[php]
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.html/$1 last;
}
}</div>
[/php]

apache 下的解决方法:

[php]
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.(php|html|htm) HTTP/
RewriteRule ^index.(php|html|htm)$ http://www.kejianet.com/ [R=301,L]
[/php]

如果是虚拟主机用户,以上方法就不适用了。用如下方法可完美解决问题。

修改.htaccess 的解决方法:

[php]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.(php|html|htm) HTTP/
RewriteRule ^index.(php|html|htm)$ http://www.xxx.com/ [R=301,L]
RewriteRule ^index.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
[/php]

把如上.htaccess 文件内容 copy 到贵站 web 根目录下的.htaccess 即可。