Home > other >  how to redirect a dynamic url?
how to redirect a dynamic url?

Time:01-24

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]

CodePudding user response:

You don't need any conditions, one single line should work:

RewriteRule ^page/(.*)/ /page/ [R=301,NC,L]

NC = no case L = Last (don't run anything after) R=301 = 301 redirect

CodePudding user response:

Good morning,

It doesn't work. Do you have an idea ?

I am using Wordpress CMS.

enter image description here

enter image description here

  • Related