【问题标题】:Rewrite URL with all dynamic parameters使用所有动态参数重写 URL
【发布时间】:2014-11-05 11:02:25
【问题描述】:

我对 .htaccess 重写非常陌生,我正在尝试创建规则来动态重写 URL。

例如,假设用户输入以下 URL:

这是我的基本网址 -

http://lptpl.info/oCatalog/

现在的 URL 可能是这样的

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  ...

【问题讨论】:

    标签: .htaccess url redirect dynamic url-rewriting


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2016-01-07
      • 2021-09-23
      • 1970-01-01
      • 1970-01-01
      • 2022-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多