Reputation: 4328
I need to create a RewriteRule on my .htaccess file which removes the Path ("page-2") if it's included at the end of the URL. So for example:
http://myhost.com/path/page-2
should redirect to:
http://myhost.com/path
I've found a similar solution on SO:
RewriteEngine On
RewriteRule ^([^/.]+)/?$ /$1/page-2/ [L]
However it does not work for me. No redirection happens. Any help?
Upvotes: 3
Views: 968
Reputation: 785146
You need to have this rule:
RewriteEngine On
RewriteRule ^(.+?)/page-2/?$ /$1 [L,NC,R=301]
Upvotes: 3