WordPress的Permalinks与guid

这几天研究wordoress的时候,纠结在Permalinks和guid究竟有什么区别,官方对于这两个东西的解析是这样的:

Permalinks:

Permalinks are the permanent URLs to your individual weblog posts, as well as categories and other lists of weblog postings. A permalink is what another weblogger will use to link to your article (or section), or how you might send a link to your story in an e-mail message. The URL to each post should be permanent, and never change — hencepermalink.

guid:

(string) A link to the post. Note: One cannot rely upon the GUID to be the permalink (as it previously was in pre-2.5), Nor can you expect it to be a valid link to the post. It’s mearly a unique identifier, which so happens to be a link to the post at present.

据此,所以我认为Permalinks就是文章的链接,而guid只不过是一个唯一标识,也可能是pre-2.5以前的遗留物…所以如果你需要得到文章的链接,也就是需要获得permalink,而不是guid,因为它甚至可能不是一个合法的链接。

在Google里搜了很久,发现guid几乎只在WordPress的RSS中用到,在WordPress的fr:Marqueurs de Modele里可以找到这个函数

Description:
Affiche le nom d’une ou plusieurs catégories auxquelles appartient l’article au format RSS (en anglais). Ce marqueur doit être utilisé à l’intérieur de la Boucle.

Utilisation:
<?php the_category_rss(‘type’) ?>

在官方的Forums里(http://wordpress.org/support/topic/70616)也看到有一位高人这样描述:

Simply put, the GUID can be thought of as an unique ID — WP uses URIs and if you happen to change your URI, the GUID will not update because simply put, it does not need to.

However ‘sloppy’ this may appear it will not matter because as an example where the GUID appears in your RSS2 feed you will note: isPermaLink="false" which as stated by the spec:

isPermaLink is optional, its default value is true. If its value is false, the guid may not be assumed to be a url, or a url to anything in particular. (http://blogs.law.harvard.edu/tech/rss#ltguidgtSubelementOfLtitemgt)

So fear not, the GUIDs in your DB (though they may look sloppy because of a URI change) will not hurt you 🙂

另外当需要把blog迁移域名的时候也需要修改guid。

我们在WordPress的”设置”->”固定链接”里可以找到对Permalinks的设置,不过需要对配置文件作一些修改,否则一般情况下都会出现404错误,我在这里做一个总结:

1. WrodPress的.htaccess文件要开放写权限,这个可通过FTP工具进行设置

2. 在Apache的httpd.conf文件中找到LoadModule rewrite_module modules/mod_rewrite.so,取消前面的#

3. 同样在httpd.conf中查找指向WordPress安装目录的Directory tag,对其中的AllowOverride参数设置为FileInfo,关于AllowOverride的详细介绍,可参见http://www.phperz.com/server/Apache/102H05320092053.html

5 thoughts on “WordPress的Permalinks与guid”

Comments are closed.