2014-09-11 96 views
0

我對.htaccess重寫很新,我試圖創建規則來動態地重寫URL。用所有動態參數重寫URL

例如,假設用戶輸入以下網址:

這是我的基本URL -

http://lptpl.info/oCatalog/ 

現在網址也能像

http://lptpl.info/oCatalog/category OR 
http://lptpl.info/oCatalog/category/abc OR 
http://lptpl.info/oCatalog/anything/xyz OR 
http://lptpl.info/oCatalog/anythingNewAgainHere/xyz OR 
http://lptpl.info/oCatalog/anything/anything OR 
http://lptpl.info/oCatalog/anything/anything/anything... 

所以我想使它就像

http://lptpl.info/oCatalog/category.html 
http://lptpl.info/oCatalog/category/abc.html 
http://lptpl.info/oCatalog/anything/xyz.html 
http://lptpl.info/oCatalog/anythingNewAgainHere/xyz.html 
http://lptpl.info/oCatalog/anything/anything.html 
http://lptpl.info/oCatalog/anything/anything/anything.html ... 

回答

0

看起來你只是想添加虛擬.html擴展名。以root身份擁有此規則.htaccess:

RewriteEngine On 

RewriteCond %{THE_REQUEST} \s/+(oCatalog/.+?)\.html[\s?] [NC] 
RewriteRule^/%1 [R=302,L,NE]