【发布时间】:2015-11-25 13:37:43
【问题描述】:
我的申请有问题。我在我的项目中使用 CodeIgniter,并且禁止在类名中使用连字符(允许使用下划线)。但我想用连字符分隔 URL 中的单词。所以我需要用正则表达式重写 url,以用 htaccess 文件中的连字符替换下划线。 想法?
例如:
我有很多链接:
domain.tld/I_need_helpdomain.tld/I_need_regex
我想要:
domain.tld/I-need-helpdomain.tld/I-need-regex
在htaccess文件中,应该有:
RewriteRule ^(.*)_(.*)$ /$1-$2
【问题讨论】:
标签: regex .htaccess codeigniter hyphen