关于wordpress
删除 index
.php
:首先登录 WordPress
后台;然后选择“设置固定链接”,设置链接;然后设置 WordPress
重写规则;最后,在 WordPress
网站目录中创建新的 htaccess
文件。
主要有两个步骤:
1.登录 WordPress
后台,选择“设置-固定链接-自定义结构”设置链接。
Apache
重写方案:
创建新的。并编写下面的代码。
RewriteEngine
On
RewriteBase
/wordpress
/
RewriteRule
^index
\.php
$ - [L
]
RewriteCond
%{REQUEST_FILENAME
} !-f
RewriteCond
%{REQUEST_FILENAME
} !-d
RewriteRule
. /wordpress
/index
.php
[L
]
Nginx
改写方案:
编辑 nginx
的配置文件 nginx
.cnf
,在 server
{} 配置内容中,写入下面的代码:
location
/ {
if
(-f
$request_filename
/index
.html
){
rewrite
(.*) $1/index
.html
break
;
}
if
(-f
$request_filename
/index
.php
){
rewrite
(.*) $1/index
.php
;
}
if
(!-f
$request_filename
){
rewrite
(.*) /index
.php
;
}
}
然后重启 nginx
/ Apache
,这样就能把 wordpress
链接中的 index
.php
去掉。
转载请注明:汇站网 » 利用 WordPress
去除 index
.php
的方法