-
當前位置:首頁 > 創(chuàng)意學院 > 技術 > 專題列表 > 正文
wordpress固定鏈接(wordpress固定鏈接修改了不能訪問)
大家好!今天讓創(chuàng)意嶺的小編來大家介紹下關于wordpress固定鏈接的問題,以下是小編對此問題的歸納整理,讓我們一起來看看吧。
開始之前先推薦一個非常厲害的Ai人工智能工具,一鍵生成原創(chuàng)文章、方案、文案、工作計劃、工作報告、論文、代碼、作文、做題和對話答疑等等
只需要輸入關鍵詞,就能返回你想要的內(nèi)容,越精準,寫出的就越詳細,有微信小程序端、在線網(wǎng)頁版、PC客戶端
官網(wǎng):https://ai.de1919.com。
創(chuàng)意嶺作為行業(yè)內(nèi)優(yōu)秀的企業(yè),服務客戶遍布全球各地,如需了解SEO相關業(yè)務請撥打電話175-8598-2043,或添加微信:1454722008
本文目錄:
一、如何設置wordpress固定鏈接
wordpress后臺---設置---固定連接---自定義結構---在空白處填:/%postname%.html 就是域名+postname.html 其中postname就是你寫文章時的文章別名,在寫文章時文章標題下可以編輯這個postname, 當然,你也可以在后臺固定連接---中選擇其他形式的網(wǎng)址組成
二、wordpress固定鏈接的wordpress固定鏈接的結構
這里有幾個結構可以作為參考:
%year% 日志發(fā)表的年份,四位數(shù)字
%monthnum% 日志發(fā)表的月份
%day% 日志發(fā)表的日期
%hour% 日志發(fā)表的時間-小時
%minute% 日志發(fā)表的時間-分鐘
%second% 日志發(fā)表的時間-秒
%postname%日志標題的縮略版本(日志/頁面編輯界面上的日志別名)。因此“This Is A Great Post!”在URI中會變成this-is-a-great-post。
%post_id%日志的唯一ID,如123
%category%分類名稱的縮略版本(添加新分類/編輯界面上的分類別名)。嵌套的子分類會作為嵌套子目錄出現(xiàn)在URI中。出于運行方面的考慮,不推薦以%category%作為固定鏈接的起始部分。
%tag%標簽名稱的縮略版本(添加新標簽/編輯界面上的標簽別名)。出于運行方面的考慮,不推薦以%tag%作為固定鏈接的起始部分。
%author%作者名稱的縮略版本.
既然知道了我們就可以對這些開始組合了。
幾種組合方式如下
/?p=%post_id%(默認的)
/%year%/%monthnum%/%day%/%postname%/(年/月/日/日志名)
/%year%/%monthnum%/%postname%/(年/月/日志名)
/%monthnum%/%day%/%postname%/(月/日/日志名)
/%year%/%monthnum%/%day%/%post_id%/(年/月/日/日志id號)
/%year%/%monthnum%/%post_id%/(年/月/日志id號)
/%monthnum%/%day%/%post_id%/(月/日/日志id號)
/archives/%post_id%(/archives/日志id號)
/archives/%postname%(/archives/日志名)
/%post_id%(/日志id號)
/%postname%(/日志名)
/%category%/%postname%.html (分類/日志名.html)
/%category%/%postname%.htm(分類/日志名.htm)
/%postname%.html(/日志名.html)
/%postname%.htm(/日志名.htm)
/%post_id%.html(/日志id號.html)
/%post_id%.htm(/日志id號.htm)
常用的就是以htm后者html方式結尾的。當然這個可以隨你的喜好自由改變。
win主機IIS 6 WordPress固定連接的設置
一般使用wordpress都會將設置固定鏈接(偽靜態(tài)),這樣更有利于seo,wordpress在LINUX系統(tǒng)的服務器中可以很好的使用,在Windows主機,為了完美支持偽靜態(tài)就需要下點功夫。
空間需要支持rewrite組件,現(xiàn)在幾乎所有WIN主機都支持Rewrite 組件,有個問題就是,博客鏈接能偽靜態(tài),可中文標簽的鏈接打不開,比如我們設置的中文目錄中文tag,就打不開了。解決WordPress博客偽靜態(tài)中文標簽無法打開可以使用下面的規(guī)則:
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
RewriteRule /tag/(.*) /index.php?tag=$1
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
# Rules to ensure that normal content gets through
RewriteRule /robots.txt /robots.txt [L]
RewriteRule /sitemap.xml /sitemap.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]
在使用上有什么不清楚請查看下面的參考資料,有詳細的設置教程 很多朋友主站并不想放博客,有的朋友喜歡美觀想放一個主頁什么的,有的是公司的網(wǎng)站,或者有的朋友想做淘寶客,那么這樣只能把WordPress放到二級目錄(子目錄)里面了,wordpress在二級目錄的偽靜態(tài)規(guī)則規(guī)則:
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
# Rules to ensure that normal content gets through
RewriteRule /blog/sitemap.xml /blog/sitemap.xml [L]
RewriteRule /blog/favicon.ico /blog/favicon.ico [L]
# For tag
RewriteRule /blog/tag/(.*)/page/(d+)$ /blog/index.php?tag=$1&paged=$2
RewriteRule /blog/tag/(.+)$ /blog/index.php?tag=$1
# For category
RewriteRule /blog/category/(.*)/page/(d+)$ /blog/index.php?category_name=$1&paged=$2
RewriteRule /blog/category/(.*) /blog/index.php?category_name=$1
# For file-based wordpress content (i.e. theme), admin, etc.
RewriteRule /blog/wp-(.*) /blog/wp-$1 [L]
# For normal wordpress content, via index.php
RewriteRule ^/blog/$ /blog/index.php [L]
RewriteRule /blog/(.*) /blog/index.php/$1 [L]
#For page
RewriteRule /blog/page/(.*)/?s=(.*) /blog/index.php?s=$2&paged=$1
RewriteRule /blog/page/(.*) /blog/index.php?paged=$1
如果在規(guī)則使用上有什么不明白的地方請查看下面的參考資料詳細教程 如果根目錄和子目錄同時裝wordpress程序,該怎么實現(xiàn)偽靜態(tài)?
固定鏈接設置規(guī)則:
[ISAPI_Rewrite]# 3600 = 1 hourCacheClockRate 3600RepeatLimit 32# For subRewriteRule /wordpress/sitemap.xml /wordpress/sitemap.xml [L]RewriteRule /wordpress/favicon.ico /wordpress/favicon.ico [L]RewriteRule /wordpress/tag/(.*)/page/(d+)$ /wordpress/index.php?tag=$1&paged=$2RewriteRule /wordpress/tag/(.+)$ /wordpress/index.php?tag=$1RewriteRule /wordpress/category/(.*)/page/(d+)$ /wordpress/index.php?category_name=$1&paged=$2RewriteRule /wordpress/category/(.*) /wordpress/index.php?category_name=$1RewriteRule /wordpress/wp-(.*) /wordpress/wp-$1 [L]RewriteRule ^/wordpress/$ /wordpress/index.php [L]RewriteRule /wordpress/(.*) /wordpress/index.php/$1 [L]RewriteRule /wordpress/page/(.*)/?s=(.*) /wordpress/index.php?s=$2&paged=$1RewriteRule /wordpress/page/(.*) /wordpress/index.php?paged=$1# For rootRewriteRule /tag/(.*) /index.php?tag=$1RewriteRule /robots.txt /robots.txt [L]RewriteRule /sitemap.xml /sitemap.xml [L]RewriteRule /favicon.ico /favicon.ico [L]RewriteRule /wp-(.*) /wp-$1 [L]RewriteRule /wordpress/(.*) /wordpress/$1 [L]RewriteRule ^/$ /index.php [L]RewriteRule /(.*) /index.php/$1 [L]
關于規(guī)則使用設置,詳細圖文教程請查看下面的參考資料
win主機IIS 7 WordPress固定連接的設置
“美觀的”固定鏈接通常會要求使用mod_rewrite,而IIS(常見于Windows服務器)卻不支持mod_rewrite。(如果你在Windows上使用Apache 2.0.54,mod_rewrite可能會運行,前提是要在apacheconfhttpd.conf.中激活mod_rewrite)。
使用IIS 7并具備服務器管理權限時,可以使用Microsoft的URL重寫模塊來代替mod_rewrite。雖然IIS 7不完全兼容mod_rewrite,但它支持WordPress的固定鏈接。Microsoft的URL重寫模塊安裝完畢后,在WordPress目錄下打開web.config文件,將以下規(guī)則添加到system.webServer 元素中:
<rewrite>
< rules>
< rule name=Main Rule stopProcessing=true>
< match url=.* />
< conditions logicalGrouping=MatchAll>
< add input={REQUEST_FILENAME} matchType=IsFile negate=true />
< add input={REQUEST_FILENAME} matchType=IsDirectory negate=true />
< /conditions>
< action type=Rewrite url=index.php />
< /rule>
< /rules>
< /rewrite>
win主機 IIS 7偽靜態(tài)規(guī)則的具體使用方法可以查看下面參考資料
IIS網(wǎng)站上有一份關于Microsoft的URL重寫模塊詳細的安裝指南,該模塊可用于 x64 與x86系統(tǒng)。
如果這個方法行不通,還可以試試PATHINFO鏈接;將index.php/放在自定義鏈接結構的開始部分前:
/index.php/%year%/%monthnum%/%day%/%postname%/這個方法并不總能成功,尤其是用在運行于ISS 6上的WordPress時。要讓這方法運行在IIS上,需要將以下兩行代碼添加到php.ini文件并將文件保存在網(wǎng)絡根目錄下。
cgi.fix_pathinfo = 1
cgi.force_redirect = 0
另一種解決方法是利用IIS的自定義404重定向。這要求你的虛擬主機允許你添加自定義404重定向,不過這并不需要你安裝任何第三方mod_rewrite軟件,也不需要你的固定鏈接結構以/index.php/開頭。
IIS7虛擬主機裝兩個wordpress固定鏈接設置
安裝兩個wordpress,一個在根目錄,一個在子目錄(二級目錄)偽靜態(tài)規(guī)則設置方案:
根目錄的偽靜態(tài)規(guī)則設置可以看下面參考資料
在子目錄(二級目錄)中的安裝wordpress,Web.config配置文件偽靜態(tài)代碼:
<?xml version=1.0 encoding=UTF-8?>
<configuration>
<system.webServer>
<rewrite>
<rules><remove name=wordpress/>
<rule name=wordpress patternSyntax=Wildcard>
<match url=*/>
<conditions>
<add input={REQUEST_FILENAME} matchType=IsFile negate=true/>
<add input={REQUEST_FILENAME} matchType=IsDirectory negate=true/>
</conditions>
<action type=Rewrite url=index.php/>
</rule></rules>
</rewrite>
</system.webServer>
</configuration>
詳細的設置方案,圖文教程可查看下面參考資料
三、wordpress固定鏈接的使用固定鏈接的一些問題
常見的幾個問題
若是以/%category%/%postname%/這種方式來自定義固定鏈接的時候打開的網(wǎng)址可能會出現(xiàn)亂碼,可能會打不開頁面,那是因為分類目錄和文章名字是中文引起的,這樣我們可以使用英文的別名來解決。
在創(chuàng)建wordpress固定鏈接的時候會出現(xiàn)別名設置,選擇合適的英文或者拼音。
在發(fā)布文章的時候在文件標題下方有一個固定鏈接,選擇編輯即可。
使用固定鏈接的必要條件
具有mod_rewrite模塊的Apache網(wǎng)絡服務器 在WordPress主目錄下 激活 FollowSymLinks選項 允許FileInfo directives(如 AllowOverride FileInfo 或 AllowOverride All) 一個.htaccess文件(若該文件缺失,WordPress會嘗試在用戶激活美觀的固定鏈接時創(chuàng)建一個新文件) 如果你希望WordPress自動更新.htaccess文件,需要為WordPress賦予該文件的寫入權限 當你新建或更新了一個“美觀的”固定鏈接結構后,WordPress會生成重寫規(guī)則并嘗試將重寫規(guī)則插入適當?shù)?htaccess文件。如果WordPress無法將重寫規(guī)則插入.htaccess文件,就會顯示You should update your .htaccess now(請立即升級你的.htaccess文件)這樣的信息,然后輸出重寫規(guī)則,讓你復制并粘貼到文件中(將規(guī)則置于文件結尾處)。
在WordPress 2.0以及更高版本中,你可能只需要執(zhí)行一次以上動作,因為WordPress會在內(nèi)部運行重寫規(guī)則。如果移動了WordPress主目錄的地址(博客地址),就需要重復以上動作。
WordPress會與已有的.htaccess文件合作愉快,也不會刪除任何已存在的重寫規(guī)則或其他指令。如果你有其它mod_rewrite規(guī)則,請將你的規(guī)則優(yōu)先于WordPress生成的mod_rewrite規(guī)則。
四、wordpress設置固定連接有什么有什么用
固定鏈接只是讓搜索引擎抓取時,能夠提高抓取效率。不像動態(tài)鏈接隨時都要像數(shù)據(jù)庫里面提取信息這樣對蜘蛛抓取很不利。而且也不利于優(yōu)化。因此網(wǎng)站都要設置偽靜態(tài)
以上就是關于wordpress固定鏈接相關問題的回答。希望能幫到你,如有更多相關問題,您也可以聯(lián)系我們的客服進行咨詢,客服也會為您講解更多精彩的知識和內(nèi)容。
推薦閱讀:
word文檔怎么制作標簽紙(word文檔怎么制作標簽紙圖片)