How do I replace an underscore with a dash using h

2020-04-16 13:03发布

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.

1条回答
霸刀☆藐视天下
2楼-- · 2020-04-16 13:06

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]
查看更多
登录 后发表回答