1

I am looking for a 301 wildcard redirect solution for the following. I changed the following url layout.

https://www.example.com/print-scan

to

https://www.example.com/printing

Now all old pages should be redirecting to the new URL layout, so for example:

https://www.example.com/print-scan/scanners/product1

must go to

https://www.example.com/printing/scanners/product1

How can I achieve that?

JGeer
  • 1,768
  • 1
  • 31
  • 75
  • Possible duplicate of [rewrite a folder name using .htaccess](https://stackoverflow.com/questions/1264773/rewrite-a-folder-name-using-htaccess) – CBroe Apr 23 '18 at 10:19

1 Answers1

4

You may use this rule as your very first rule:

RewriteEngine On

RewriteRule ^print-scan(/.*)?$ /printing$1 [L,NC,NE,R=301]

Pattern (/.*)? allows you match any of the following URIs:

  • /print-scan (no trailing slash)
  • /print-scan/ (with trailing slash)
  • /print-scan/anything
  • /print-scan/scanners/product1
anubhava
  • 761,203
  • 64
  • 569
  • 643