如何去除WordPress中的index.php方法

如何去除WordPress中的index.php方法

如何去除WordPress中的index.php方法,有两种方法供大家参看。

1、wordpress设置固定链接 ——登录wordpress后台——选择‘设置/固定链接’ ——选择‘自定义结构’ 。找到后根据自己的情况设置链接即可。

2、设置wordpress重写规则

这个需要根据你的web服务器来决定 ,wordpress apache静态链接重写规则

如果你是 apache,在wordpress 网站目录下,新建一个 .htaccess 文件。并写入下面的代码:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

wordpress nginx 静态链接重写规则,如果你的web服务器是 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。这样就能把 wordpress 链接中的 index.php 去掉。

如何去除WordPress中的index.php方法

相关文章:

你感兴趣的文章:

标签云: