redirect/rewrite a link to Main site in MU to a sub site

Hi Guys, hope you are all doing well

i have an external app than link back to my network site like this

wjere is my network domain URL and UniqueID is unique in the network and crosponed to particulaer sub site

how can i redirect this traffic to corresponding site?

how this will work/affect “DOMAIN MAPPING”?

  • Adam Czajczyk
    • Support Gorilla

    Hello khalid,

    I hope you’re well today and thank you for your question!

    This can be done with some custom code and shouldn’t affect Domain Mapping I think.

    What you need to do is to:

    1. read the ID from URL

    2. read some data from the database where those IDs are stored

    3. perform redirect

    As for 1)

    I think the best place to catch it would be a 404 page template file. Usually a “get_query_var()” should be used but in this case you don’t know the name of the variable to catch so you’d need to use regular PHP way:

    – get $_SERVER variable value to catch an URL

    – parse it with PHP to get ID

    As for 2)

    This depends on where/how the data is stored so I’m not able to advice anything on this not knowing about it except you shouldn’t ever handle database connection with your own code but instead use WP built-in functions.

    As for 3)

    There’s a redirect function built in into WordPress:

    That being said, I’m sorry I couldn’t provide you with more specific answer. If you are going to custom code that solution yourself and have any further questions on this, please ask and I’ll be happy to assist you and share more specific tips.

    If you need it developed for you though you may want to ask a question on our “Jobs & Pros” job board (please note: no WPMU DEV staff involved!) here:

    Best regards,


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.