如何使用 htaccess 将下划线替换为破折号?

发布于 2024-12-25 23:59:58 字数 268 浏览 1 评论 0原文

好的,这是我的网址:

http://example.com/home/process_login

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

因此,http://example.com/home/process-login 将转到上述网址,但它仍会在 URL 栏中显示 process-login

希望这是有道理的。我找到的唯一解决方案是重定向,但我不想要重定向。我希望它能像我概述的那样阅读。

Okay here is my url:

http://example.com/home/process_login

I would like to replace the underscore with a dash.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

破晓 2025-01-01 23:59:58

使用此代码:

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]

Use this code:

Options +FollowSymLinks -MultiViews
RewriteEngine on

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

UPDATE: Based on your comments below

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]

UPDATE 2: Based on your comments below

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]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文