subdomain redirects to page and stays visible in address bar

Hello,

in subdomain multisite installation, there is a need to create unusual redirect. I need to configure subdomain xxx.siteaddress.com, which redirects to siteaddress.com/contentsite and xxx.siteaddress.com needs to stay visible in address bar. This is internal configuration (subdomain to page in wordpress).

Could you please give a hint where this configuration could be done, without harming generic multisite configuration? (htaccess?)

Best regards,
Milosz

  • wash

    Hello @sjaved,

    thank you for quick reply, I'm good. How are you?

    Background is fairy simple: wordpress multisite installation runs main portal siteaddress.com and also contains several sub-portals (site1.siteaddress.com). Some content has been created and published as a page in main portal (mentioned page: siteaddress.com/seriouscontent). Customer created business around this particular content and requested presenting this page siteaddress.com/seriouscontent as subdomain page content.siteaddress.com.

    This could be achieved by simply redirecting subdomain, but condition was for the whole section to 'appear" as separate page (under subdomain). Therefore, content.siteaddress.com must stay in address bar - simple redirect is not sufficient.

    I was wondering if there is any way to get configuration close to customer request (via dns or htaccess?). What I mean is visitor goes to siteaddress.com/seriouscontent as sees content.siteaddress.com in address bar.

    If not, content needs to be moved to separate page in multisite, which costs more effort that configuration, probably. Hope this helps, in case of any questions I'll provide more. Thank you for your time.

    Best regards and thank you for reply,
    Milosz

  • Ivan Shulev

    Hey Milosz,

    I hope you are having an awesome day!

    From what I understand (correct me if I'm wrong), siteaddress.com/seriouscontent holds custom content that needs to be accessed by a subdomain of the main install while the address remains the same in the browser.

    This can be achieved with Apache proxy (https://httpd.apache.org/docs/2.4/mod/mod_proxy.html). Make sure to enable that module first.

    Then you can add the following code right after the opening RewriteEngine On directive in your .htaccess file. It is important for this rule to be the first in the file, otherwise it might not be reached. The code also assumes you do not have SSL enabled.

    RewriteCond %{HTTP_HOST} ^site1\.siteaddress\.com$ [NC]
    RewriteRule ^(.*)$ http://siteaddress.com/seriouscontent/$1 [P]

    For example, http://siteaddress.com/seriouscontent/page.html can now be reached by http://site1.siteaddress.com/page.html.

    The "[NC]" flag makes sure that the match (site1.siteaddress.com) is not case-sensitive. The "[P]" flag tells Apache to proxy the request (the important flag).

    If you are using SSL, you would have to adjust the code accordingly.

    You can debug the redirect with RewriteLog - https://wiki.apache.org/httpd/RewriteLog

    Please share how it turns out and I will be happy to assist you further.

    Have a nice day!

    Ivan

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.