If you are wanting to redirect specific URLs, as in your examples, then you could do something like the following using mod_rewrite at the top of your
RewriteRule ^(vloerafwerking/)projecttapijt/raamafwerking/ /$1 [R=302,L]
RewriteRule ^(vloerafwerking/)projec4/raamafwerking/ /$1 [R=302,L]
These will need to be arranged in order specificity - if you have conflicting directives. The most specific rules should be first.
$1 backreference is simply to avoid having to repeat the base directory name.
These are 302 (temporary) redirects. Change to a 301 (permanent) redirect - if that is the intention - only after you have confirmed that it works OK. This is to avoid the browser caching erroneous redirects whilst testing.
However, if you are wanting to redirect any URL that simply starts
/vloerafwerking/ as suggested by your code sample then you could do the following instead:
RewriteRule ^(vloerafwerking/). /$1 [R=302,L]
The dot (
.) at the end of the
RewriteRule pattern matches a single character, so it matches
/vloerafwerking/<something>, and not
/vloerafwerking/ (which would create a redirect loop).
RewriteRule ^vloerafwerking/([a-zA-Z0-9])$ /vloerafwerking/$1[R=301]
There are a number of "errors" with your attempt:
([a-zA-Z0-9])$ - This matches just a single character in the range
0-9 after the directory name. Your example URLs consist of more than 1 character, so you either need to add the
+ quantifier (1 or more characters) or remove the
$ anchor. You also need to match
/ (slash) - which is missing from the character class.
$1 - Not sure why you are capturing the URL-path you are wanting to remove and using this in the substitution? This is exactly what you don't want to do; you want to remove, not add it back again. (This would also result in a redirect loop.)
.../$1[R=301] - You are missing a space delimiter before the flags argument. This would result in a malformed redirect. You need a space:
You are also missing the
L flag, so processing would continue through the file. (Unless this is already the last directive.)