Regex .htaccess从所有url转换为

Regex .htaccess从所有url转换为,regex,apache,.htaccess,mod-rewrite,Regex,Apache,.htaccess,Mod Rewrite,原始URL:/icon/line-vector-icons-1-2/chatting\u bubble-\u talk-\u comments-\u chat-\u online\u conversation-62 通缉URL:/icon/line-vector-icons-1-2/chating-bubble-talk-comments-chat-online-conversation-62 “”和“-”或“-”应该类似于- 如果我的问题已经在其他地方得到了回答,请告诉我,并请随时编辑和更正我

原始URL:
/icon/line-vector-icons-1-2/chatting\u bubble-\u talk-\u comments-\u chat-\u online\u conversation-62

通缉URL:
/icon/line-vector-icons-1-2/chating-bubble-talk-comments-chat-online-conversation-62

”和“
-
”或“
-
”应该类似于
-
如果我的问题已经在其他地方得到了回答,请告诉我,并请随时编辑和更正我的问题

这个问题有点像问题,但它不符合我的要求,或者可能是我做错了什么这是我使用的.htaccess。如果有什么问题,请告诉我

RewriteEngine on
RewriteBase /icooons/
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA]
RewriteRule (.*)_(.*) $1-$2 [N]

您可以使用此递归规则(请参阅我的内联注释):


也许吧?对不起,我试过了,但似乎不管用。。你能帮我找出我做错了什么吗?我不想重定向url,我只想转换“
-
”、“
-
”、“
-
”。解决方案不起作用。嗨,谢谢。有没有办法不重定向?我的意思是我只是想转换它或者只是隐藏它,而不是重定向它,如果我这样做,整个页面将像404一样找不到。你说隐藏是什么意思?一旦将
-
转换为
-
后,任何代码都无法将
-
返回URL,因为它可能最初是
-
-
-
。希望你明白我的意思。我的意思是说我真正的页面是test_1,使用你的代码将使它成为test-1。是否可能浏览器将其视为test_1,但在地址栏中它看起来像test-1,这样我的页面将不会转到404..浏览器会看到显示的URL。使用其他规则或代码
test-1
可以转换为
test\u 1
。但问题是,如果原始URL混合了
\uu
-
,并且URL看起来像
test-1\u2\u3
,那么转换后它将变成
test-1-2-3
。现在的问题是如何在内部将其转换回
test-1\u 2\u 3
,因为用
\u
替换
-
将使其
test\u 1\u 2\u 3
不正确。+1谢谢我理解。我希望我能找到一个解决我的问题的方法,但似乎这是不可能的,因为url不断变化,他们也没有办法将url存储在变量或会话中,然后使用它。。谢谢你的帮助。
RewriteEngine On
RewriteBase /icon/

# keep replacing underscores to hyphen until there is no _ (use internal rewrite)
RewriteRule ^(.*?)(?:_-?|-_)(.*)$ $1-$2 [E=USCORE:1,DPI]

# when there is no underscore make an external redirection
RewriteCond %{ENV:USCORE} =1
RewriteRule ^([^_]+)$ $1 [NE,R=302,L]

RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]