2017-04-24 82 views
0

問題: 我有一個頁面,顯示簡檔:「www.example.com/profile/1」WordPress的,使用蛞蝓爲變量不是作爲頁蛞蝓

「1」是所述配置文件的ID,我從URL中檢索ID並撥打外部文件來檢索配置文件信息。

這一切工作正常。

但我現在想使用配置文件名稱而不是ID:'www.example.com/profile/nameOfProfile',Wordpress現在搜索名爲'nameOfProfile'的頁面,該頁面顯然不存在。

我現在的問題是:我怎樣才能讓網址'www.example.com/profile/nameOfProfile'加載頁面'www.example.com/profile',以便我可以手動檢索名稱該網址並撥打個人資料?

回答

0

首先,你需要通過「nameOfProfile」的URL爲下面給出,

www.example.com/profile?name="nameOfProfile" 

然後你需要爲下面給出重寫URL,

RewriteRule ^profile/([^/]*)/? /profile/?name=$1 [QSA,L]