Htaccess - rewriting part of a file name

Hello,

I just made a change to my site and have a lot of links that I need to direct. The problem is I am trying to regex match a word inside the url and remove it, for example: burger-joint-is-tasty.html find links with word “joint” and remove for new url burger-is-tasty.html

So far all I have been able to find are resources for changing the entire directory. The reason I need to just change one word is because everything before and after that is going to be different.

Thanks for any help

nt sure but may be it can be done via this rule

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^(.)undesired-string(.)$ yoursite.com/$1new-string$2 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?/$1 [L]

RewriteCond %{HTTP_HOST} !^www.yoursite.com$ [NC]
RewriteRule ^(.*)$ yoursite.com//$1 [L,R=301]
</IfModule>

or just try this

RewriteRule ^(.)undesired-string(.)$ $1new-string$2 [R=301,L]

or this
RewriteRule ^(.)undesired-string(.)$ http://yoursite.com/$1new-string$2 [R=301,L]

I’ll give that a try. Thanks!

That’ll do it - EXCEPT for the insane <IfModule> conditionals which must be run multiple times for each and every file request, i.e., ABUSE of the Apache server and certain reason to prohibit your existence on a shared server!

Regards,

DK