wordpress去除index.php的方法

更新于 2020年10月25日 wordpress教程

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

主要有两个步骤:

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.conf,在 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开启多站点方法wordpress开启多站点方法

本文介绍一下wordpress开启多站点以及开启多站点之后nginx的配置。 rewrite (.*) $1/index.php; rewrite (.*) /index.php;

wordpress去除index.php的方法wordpress去除index.php的方法

wordpress去除index.php的方法:首先登录wordpress后台;1-2-2) wordpress nginx 静态链接重写规则这样就能把 wordpress 链接中的 index.php 去掉。

通过 wp-config.php 在 wordpress 上正确强制 SSL通过 wp-config.php 在 wordpress 上正确强制 SSL

如果我编辑wp-config.php我应该添加:(.*) https://%{SERVER_NAME}/$1 [ wp_redirect(‘https://’ . $_SERVER[

自动图片插件入门教程自动图片插件入门教程

欢迎使用WordPress自动图片插件。进入正文图选项,开启文章配图,如下:这个设置稍微麻烦一点,如果您是WordPress资深用户且不希望配图消耗磁盘空间,建议尝试使用该高级特性。

wordpress文章自动配图、缩略图插件:wpacwordpress文章自动配图、缩略图插件:wpac

现在写点文章不配图总觉得文章质量不太高。于是萌生了写一款文章自动配图的插件的想法。文章页自动加一张图比较简单,从候选集中选择一张图片拼接在正文中即可。又比如在图片中添加文章标题,摘要或者自定义的文字。

wordpress怎么调用特定文章列表wordpress怎么调用特定文章列表

a href=”< //cat=1为调用ID为1的分类下文章”title=”<

wordpress如何在一个页面显示所有文章wordpress如何在一个页面显示所有文章

让WordPress一个页面显示全部分类的文章cat=’ . $cat->php echo $cat->a href=”<$cats = get_categories(array(‘include’ =>

wordpress怎么获取某个栏目链接地址wordpress怎么获取某个栏目链接地址

” title=”Category Name”>$cat_links=get_category_link($cat->php echo $cat->

好看 (0) 很好看 (0) 非常好看 (0)