簡體   English   中英

博客標題自動出現

[英]blog titles to come automatically

我希望在用PHP開發的博客中,URL應該看起來像http://mysite.com/jan2006/best-day-of-my-life,而不是這樣的http://mysite.com/ viewblog.php?id = 25 “我生命中最好的一天”是我的博客文章的標題,我該使用哪種工具自動執行此操作? 這項技術是否有助於搜索引擎優化?

您需要使用.htaccess和Apache的mod_rewrite Google&SO上有大量信息:

http://www.javascriptkit.com/howto/htaccess.shtml

http://www.besthostratings.com/articles/htaccess.html

http://www.bloghash.com/2006/11/beginners-guide-to-htaccess-file-with-examples/

但是,需要注意的一件事是,在您給出的示例中,您仍然需要URL中特定博客帖子的唯一標識符(即ID),例如:

http://mysite.com/jan2006/best-day-of-my-life ,而不是像這樣http://mysite.com/viewblog.php?id=25

實際上需要是:

http://mysite.com/25/jan2006/best-day-of-my-life

http://mysite.com/post/25/jan2006/best-day-of-my-life

如果您有Apache托管設置,則在您的根目錄中將需要一個名為“ .htaccess”的文件。 它的內容看起來像(例如):

# set up mod rewrite
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^post/(.*)/(.*)/(.*)$ viewblog.php?id=$1 [NC,L] # Handle requests for clean urls to blog posts

至於

此技術有助於搜索引擎優化嗎?

是的,是的:

http://www.seocentro.com/articles/apache/mod_rewrite-seo-purposes.html

http://techie-buzz.com/how-to/create-seo-friendly-urls-using-mod-rewrite-and-php-part-1.html

http://www.seomoz.org/ugc/using-mod-rewrite-to-convert-dynamic-urls-to-seo-friendly-urls

http://webhostinggeeks.com/blog/2011/03/31/seo-friendly-links-with-mod_rewrite/

在管理控制台中,查看您的設置,然后應該有一個稱為永久鏈接的部分。 在這里,您可以更改永久鏈接的顯示方式。

http://codex.wordpress.org/Using_Permalinks#Structure_Tags

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM