我是.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 ...
答案 0 :(得分:0)
看起来您只是想添加虚拟.html
扩展名。在root .htaccess中有这个规则:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+(oCatalog/.+?)\.html[\s?] [NC]
RewriteRule ^ /%1 [R=302,L,NE]