How to use a common header in multiple subdomains

My application has several modules. Each module is hosted in a different subdomain. for example: subdomain1 / abc.com subdomain2 / abc.com subdomain3 / abc.com

I want to use a common header file among the pages of other modules. How can i do this.

+4
source share
2 answers

Let's say you have the main domain "abc.com" (the real path is "/", since all files fall under " public_html " or " httpdocs "). Now you will need to create one directory (say, "common_includes") in this main domain, inside which you can store all the usual included files (for example, header and footer files).

Say your header and footer files will be "header.php" and "footer.php". Thus, these files will be available as "/common_includes/header.php" and "/common_includes/footer.php" in any function that includes PHP that requires mention of Real Paths.

Now, if you use the above two real paths in the "include_once ()" method in any of your subdomains, you will be able to include these files (header and footer files) in relation to the subdomain you are using. This is how it works normally.

Hope this helps.

+1
source

Are they all on the same server? are they all on the same virtual host?

if so, you can put the common_files folder parallel to the available folders in the subdomain and include them from there.

Itโ€™s hard to say if you donโ€™t give us the specifics with your customization.

0
source

Source: https://habr.com/ru/post/1314713/


All Articles