簡單粗暴的去除 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 即可。