Reputation: 99
I want to redirect /event/path1/{id}/{some_name} to /event/path2/{id},
I want to redirect old page to the new one and remove the last segment of the url,
I have done with this but not removing the last segment of the url, this is what .htaccess
RewriteRule ^event/path1/(.*) /event/path2/$1 [L,R=301]
Upvotes: 0
Views: 26
Reputation: 786349
You're using .*
in your regex that matches everything after /event/path1/
thus resulting in wrong target URL.
You may use:
RewriteRule ^event/path1/([^/]+)/[^/]+/?$ /event/path2/$1? [L,R=301,NC]
Here [^/]+
will match 1 or more of any non-slash character.
?
at the end of the target will strip off any previous query string.
Upvotes: 1