I have a URL www.example.com/page/abcderf
=> abcderf
<= is dynamic, it is never the same value.
I would like to redirect with .htacess
from :
www.example.com/page/abcderf
to
www.example.com/page/
How to do ?
My attempt:
RewriteCond %{REQUEST_URI} (\page\.[a-zA-Z0-9])$
RewriteRule ^(.+)/$ http://www.example.com/page/ [R=301,L]
/abcderf
/ [a-zA-Z0-9]
- Do you need to be specific with what comes after /page/
? Or is it OK to match any URL that simply starts with /page/
? Your example URL does not end with a slash, except that your RewriteRule
specifically matches only URLs that do end with a slash? You don't need any conditions, one single line should work:
RewriteRule ^page/(.*) /page/ [R=301,NC,L]
or as MrWhite mentioned if you don't need to know what was in the URL
RewriteRule ^page/. /page/ [R=301,NC,L]
NC = no case L = Last (don't run anything after) R=301 = 301 redirect
^page/.
(no need for the capturing subgroup). Good morning,
It doesn't work. Do you have an idea ?
I am using Wordpress CMS.