使用所有动态参数重写URL

时间:2014-09-11 13:12:17

标签: .htaccess url redirect dynamic url-rewriting

我是.htaccess重写的新手,我正在尝试创建动态重写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  ...

1 个答案:

答案 0 :(得分:0)

看起来您只是想添加虚拟.html扩展名。在root .htaccess中有这个规则:

RewriteEngine On

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