Setting up multiple redirect rules

Hello,
I need to setup multiple redirect rules and couldn't find a clear instruction here or elsewhere.

1/Recently, I placed the following redirects.

RewriteRule ^subsite2/(.*) ^/$1? [R,L]
RewriteRule ^blog/(.*) ^/$1? [R,L]

2/Now, I want to add a new rule to redirect the uploads from subsite2 to the main site.
Since WordPress is installed in its own directory, the image urls of the main site are domain.com/subdirectory/wp-content/uploads/. (Should it be like that?)

Therefore, I need to redirect images urls from subsite2 to the main site.
I think I can use this to do that:
RewriteRule ^subsite2/wp-content/uploads/sites/2/(.*) ^subdirectory/wp-content/uploads/$1? [R,L]

However, that would conflict with the RewriteRule above (on number 1) which redirect all urls preceeded by /subsite2/. Right?

How can I setup multipl rules?
To redirect:

domain.comsubsite2/yyyy/mm/dd/post-name/ to
domain.com/yyyy/mm/dd/post-name/
domain.com/subsite2/wp-content/uploads/sites/2/.... to
domain.com/subdirectory/wp-content/uploads/...`

Thanks in advance.

  • Kasia Swiderska
    • Support nomad

    Hello Daniel,

    In rewrites orders means a lot, so you should first put redirect

    RewriteRule ^subsite2/wp-content/uploads/sites/2/(.*) ^subdirectory/wp-content/uploads/$1? [R,L]

    and then the less specific rule

    RewriteRule ^subsite2/(.*) ^/$1? [R,L]
    RewriteRule ^blog/(.*) ^/$1? [R,L]

    can you try this and let me know if this work for you?

    kind regards,
    Kasia

  • Nithin
    • Support Wizard

    Hi Daniel Berhane,

    Sorry for the delay in getting back to you, were you able to resolve this issue? I'm not able to notice %5e when I tested the above rules in my system, maybe I'm missing something here.

    If you still have issues, I could check this with one of our .htaccess experts to see what's being missed here. Please do let us know, have a nice day. :slight_smile:

    Best Regards,
    Nithin

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.