Home > CMS Tutorial > WordPress > How to remove index.php in wordpress

How to remove index.php in wordpress

藏色散人
Release: 2020-09-08 14:54:40
Original
8740 people have browsed it

wordpress去除index.php的方法:首先登录wordpress后台;然后依次选择“设置-固定链接”并设置好链接;接着设置wordpress重写规则;最后在wordpress网站目录下新建htaccess文件即可。

How to remove index.php in wordpress

wordpress去掉index.php的方法

主要有两个步骤:

1-1) wordpress设置固定链接

登录wordpress后台,

依次选择‘设置/固定链接’

在出现的页面中,

选择‘自定义结构’

然后根据你的情况,

设置好链接。

1-2) 设置wordpress重写规则

这个需要根据你的web服务器来决定

1-2-1) 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>
Copy after login

1-2-2) 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;
    }
}
Copy after login

然后重启 nginx

这样就能把 wordpress 链接中的 index.php 去掉。

The above is the detailed content of How to remove index.php in wordpress. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template