【问题标题】:rewrite rule with regex to add forward slash用正则表达式重写规则以添加正斜杠
【发布时间】:2015-05-19 14:52:24
【问题描述】:

我想知道如何打开这个网址:

https://www.mywebsite.com/online/param1/param2

进入

https://www.mywebsite.com//online/param1/param2

或进入

https://www.mywebsite.com/en/online/param1/param2

谢谢大家!

【问题讨论】:

    标签: regex apache .htaccess mod-rewrite url-rewriting


    【解决方案1】:

    您可以在 root .htaccess 中使用此规则:

    RewriteEngine On
    
    # case 1
    RewriteCond %{THE_REQUEST} !\s//
    RewriteRule ^(online/.*)$ //$1 [R=302,NC,L,NE]
    
    # case 2
    RewriteRule ^(online/.*)$ /en/$1 [R=302,NC,L,NE]
    

    【讨论】:

    • 这似乎适用于案例 2,谢谢 :) 我怎样才能让它适用于案例一?
    猜你喜欢
    • 1970-01-01
    • 2011-03-09
    • 1970-01-01
    • 2016-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-28
    相关资源
    最近更新 更多