如何更换使用htaccess的破折号下划线? [英] How do I replace an underscore with a dash using htaccess?

查看:277
本文介绍了如何更换使用htaccess的破折号下划线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好这里是我的网址:

http://example.com/home/process_login

我想用破折号替换下划线。

I would like to replace the underscore with a dash.

所以 http://example.com/home/process-login 将前往上述网址,但它仍然会SAY 流程 - 在地址栏登录

So http://example.com/home/process-login will go to the above url, but it will still SAY process-login in the URL bar.

希望这是有道理的。我发现的唯一的解决方案已经重定向,而我不希望重定向。我希望它理解为我所概述。

Hopefully this makes sense. The only solutions I've found have been redirects, and I don't want a redirect. I want it to read as I have outlined.

推荐答案

使用这种code:

Options +FollowSymLinks -MultiViews
RewriteEngine on

RewriteRule ^(home/)(.*)-(.*)$ $1$2_$3 [L,NC]

更新:根据您的意见如下

Options +FollowSymLinks -MultiViews
RewriteEngine on

RewriteCond %{REQUEST_URI} !^/?(coremeasures/index\.php/|index\.php|home/|images/|robots\.txt)
RewriteRule ^(.*)$ /coremeasures/index.php/$1 [L]
RewriteRule ^(home/)(.*)-(.*)$ $1$2_$3 [L,NC]

更新2:根据下方的评论

Options +FollowSymLinks -MultiViews
RewriteEngine on

RewriteRule ^(?!(coremeasures/index\.php/|index\.php|home/|images/|robots\.txt))(.*)$ coremeasures/index.php/$1 [L]
RewriteRule ^(home/)(.*)-(.*)$ $1$2_$3 [L,NC]

这篇关于如何更换使用htaccess的破折号下划线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆