htaccess的Wordpress自定义永久链接

htaccess的Wordpress自定义永久链接

本文介绍了使用.htaccess的Wordpress自定义永久链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我通过Admin中的永久链接设置为帖子前链接 / post /%post_id%添加了自定义结构。

Currently I added custom structure for posts premalinks /post/%post_id% through permalinks settings in Admin.

因为我需要重写类别,标签和作者页面的永久链接,如下所示:

Since I need to rewrite permalinks for categories, tags and author pages as follow:

类别

当前 / post / category / category_name / category_name

标签

当前 / post / tag / tag_name 标签/标签名

作者

当前 / post / author / author_username / author / author_username

我试图在.htaccess中创建自定义RewriteRule,但根本没有用:

I tried to create custom RewriteRule in .htaccess, which didn`t work at all:

RewriteRule ^/([^/]*)$ ./post/category/$1 [L]
RewriteRule ^/tag/([^/]*)$ ./post/tag/$1 [L]
RewriteRule ^/author/([^/]*)$ ./post/auhtor/$1 [L]

有关.htaccess规则编码为ac的任何帮助此类固定链接非常受赞赏。

Any help with .htaccess rules coding to achieve such permalinks is much appreciated.

推荐答案


  1. 确保在apache配置中已重写引擎

  2. 以管理权限登录到WordPress,然后转到设置->永久链接,如随附的三个图像所示。

  3. 如果永久链接未更新,则您无权访问网站根目录或重写apache模块

  4. 如果出现永久链接消息,则表示它还在WordPress网站的根目录中创建了.htaccess。

  1. Make sure you have rewrite engine on in your apache configuration
  2. Login to your WordPress with administrative rights and go to Settings -> Permalinks as shown into attached three images.
  3. If permalink is not updated, then you don't have write access to root of website or rewrite module of apache is not enabled.
  4. If permalink message appears, it means it also created .htaccess in the root of WordPress site.

通过这种方式,您可以实现以下网址格式:

This way you can achieve following url formats:

类别

category/category_name

标签

tag/tag_name

作者

/author/author_username



这篇关于使用.htaccess的Wordpress自定义永久链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 09:31