I've created an offsite bucket to store media files. I'm trying to redirect all of the media library (old) file URLs to the bucket (new) but need to exclude some sub-directories that do not exist on the bucket.
Is it possible to write a regex rule that copies all information after the domain and trailing slash (olddomain.com/), check it for the directories I would like to exclude, then append it after the trailing slash of the new domain?
Old
olddomain.com/files/
olddomain.com/files/sub1/
olddomain.com/files/sub2/ *(exclude from match)
olddomain.com/files/sub3/ *(exclude from match)
New
newdomain.com/files
newdomain.com/files/sub1/
Thanks in advance.
Tried...
Source
^/files/(?!sub2|sub3)(.*)
Target
newdomain.com/$1
From the looks of it, you might have forgotten /files/ in target. Nginx setup could look like this: