1

I want to redirect all files in a subdirectory to their new root URL.

Old URLS are

www.domain.com/subdirectory/filename-here.html

New location is

www.domain.com/filename.here.html

Old URLs are listed in Google already and need some sort of redirect for these. I'm sure htaccess is the way to go here, but unsure of the solution.

Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198

1 Answers1

1
RewriteEngine on
RewriteRule %{REQUEST_URI} ^/subdirectory/.*
RewriteRule subdirectory/(.*)$ /$1 [R=301,L]

Tested on here. If it would not work - add shielding to [^/] in this way: [^\/]

vmeln
  • 1,289
  • 1
  • 16
  • 40