Link to home
Start Free TrialLog in
Avatar of FourMat
FourMat

asked on

mod_rewrite Replace Underscores with hyphens in URL

Hello,

I have a RewriteRule that currently modifies a URL to be more SEO friendly

RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}

rule above will take this url and modify it

index.php?cPath=277_280

which would result in something like this:

replacement-parts-c-277_280_295.html

I need it to look like this:

replacement-parts-c-277-280-295.html

what Is for the above Rewrite rule to also replace the underscore with a dash.  I have attempted several changes, but I'm failing at regex syntax.  Is there a way to do this within the one rule above?
Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

Is the existing rule working (except for the underscores for dashes part)?

I'm guessing not, but I wanted to check.
ASKER CERTIFIED SOLUTION
Avatar of David S.
David S.
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of FourMat
FourMat

ASKER

David, and Terry, thanks for the responses.  I haven't had a chance to test these ideas (got pulled away on another project briefly)  but will definitely be back on it soon and test, thanks!