I'm wondering how I could 301 redirect all urls of the format
/search/(.*)
(where (.*) is not terminated by .html)
to
/search/$1.html
Mainly I'm just not quite sure how I can match the url structure not having .html at the end, that's my issue.
Thanks
You could use
%{REQUEST_URI}as a condition to negatively match against it, like this:I've used
302in my above example, simple because when testing I always use 302 to make sure its working so I don't get cached, once you confirm its working, you can safely switch it to[R=301,NC,L].In other words, if the URL is not
search/something.htmlit will redirect to its version with the ending.html.NOTE: Keep in mind that the order where you place this rule and your system/CMS if any can affect the result you get. If you had previously tried 301 redirects you might also be cached and it will as well affect the results.