0
votes

I posted a question here which I got an answer for, but now I've identified an issue with the code.

Original Question:

301 RedirectMatch - Many URLs

RewriteRule ^([^-]+)-([^-]+)-(?!in)([^/]+)-([^-]{2})\.html$ /$1-$2-in-$3-$4.html [R=301,L]
RewriteRule ^([^-]+)-([^-]+)-(?!in)([^/]+)\.html$ /$1-$2-in-$3.html [R=301,L]

While the above fixed all the issues with the URLs, I noticed my normal URLs are having issues. Example, domain.com/careers-jobs-music-degree.html is turning into domain.com/careers-jobs-in-music-degree.html - the 'in' is being added to other URLs that don't have 'music-classes' in the URL. Is there any way to prevent this?

Thanks!

1
Are the normal URL's real URLs or are they fake as well? - Panama Jack
those are real and in place. - user1858780

1 Answers

0
votes

You can try the rules this way so real URLs shouldn't be affected.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^-]+)-([^-]+)-(?!in)([^/]+)-([^-]{2})\.html$ /$1-$2-in-$3-$4.html [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^-]+)-([^-]+)-(?!in)([^/]+)\.html$ /$1-$2-in-$3.html [R=301,L]