温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

wordpress如何去除index.php

发布时间:2020-12-25 13:42:12 来源:亿速云 阅读:323 作者:小新 栏目:建站服务器

小编给大家分享一下wordpress如何去除index.php,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

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

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>

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;
    }
}

然后重启 nginx

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

看完了这篇文章,相信你对“wordpress如何去除index.php”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI