这是一篇很早就有人分享过的文章,不过依然还是会有很多人遇到类似的问题,下面悦然网络工作室再给大家分享一下吧。
在为就在刚刚还客户问WordPress伪静态的问题,虽然这个我在帮他们做企业网站建设时都已经做好的,后来可能他们的技术人员做过一些调整吧,反而弄出问题了。
今天这篇文章我就来跟大家说一下,关于WordPress程序在win和Linux系统下的伪静态设置方法,网站进行伪静态设置,对SEO优化是有着非常重要的作用。
第一种:win系统下的WordPress程序伪静态。
WordPress在win系统下的伪静态前提是必须空间系统支持伪静态设置,而我们也知道一般win系统支持的伪静态规则为httpd.ini格式的,那我们首先就先新建一个文本文档,将以下代码复制粘贴在里面(这是我至今为止搜集到的最完美的win系统伪静态规则)。
[ISAPI_Rewrite]
3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
Protect httpd.ini and httpd.parse.errors files
from accessing through HTTP
wordpress 伪静态规则
For tag(中文标签以及标签翻页的规则)
RewriteRule /tag/(.*)/page/(\d+)$ /index.php?tag=$1&paged= 2 R e w r i t e R u l e / t a g / ( . + ) 2 RewriteRule /tag/(.+) 2RewriteRule/tag/(.+) /index.php?tag=$1
For category(中文分类以及分类翻页的规则)
RewriteRule /category/(.)/page/(\d+)$ /index.php?category_name=$1&paged=$2
RewriteRule /category/(.) /index.php?category_name=$1
For sitemapxml
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /sitemap.html /sitemap.html [L]
RewriteRule /sitemap_baidu.xml /sitemap_baidu.xml [L]
RewriteRule /favicon.ico /favicon.ico [L]
For file-based wordpress content (i.e. theme), admin, etc.
RewriteRule /wp-(.*) /wp-$1 [L]
For normal wordpress content, via index.php
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php/$1 [L]
将以上代码复制粘贴到文本文档后,我们再将文本另存为httpd.ini,这样我们的伪静态规则就弄好了,我们只需要将这个文件上传到空间更目录,如果在后台→固定链接选择自定义链接输入/%category%/%post_id%.html或是/%post_id%.html点击保存就可以了。这样我们win系统下的WordPress程序伪静态就完成了。
第二种:Linux系统下的WordPress伪静态设置
这一种就是非常简单的,我们知道Linux系统本身使用WordPress是最完美的系统,它的伪静态设置是非常简单的,我们只需要在后台→固定链接选择自定义链接输入/%category%/%post_id%.html或是/%post_id%.html点击保存就可以了。下面我就将Linux系统支持的.htaccess伪静态规则内容写出来。代码如下:
BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
END WordPress
以上代码也是一样,需要我们新建一个文本文档,然后将代码复制粘贴进去,点击另存为.htaccess文件,再将此文件上传至空间根目录下就完成了。