views:

36

answers:

2

My application has several modules. Each module is hosted in a different sub domain. eg: subdomain1/abc.com subdomain2/abc.com subdomain3/abc.com

I want to use a common header file, among the pages in other modules also. How can I do that.

A: 

Are they all on the same Server? are they all within the same virtual host?

if so then you could put a common_files folder parallel to the subdomain web accessible folders and include them from there.

hard to say unless you give us specifics with your setup.

Lizard
+1  A: 

Let's say you have the main domain "abc.com" (whose real path is "/", as all files come under the "public_html" or "httpdocs" directory). Now you will need to create one directory (let's say "common_includes") in this main domain, inside which you can keep all the common includable files (like the header & footer files).

Let's say your header & footer files be "header.php" & "footer.php". So these files will be accessible as "/common_includes/header.php" & "/common_includes/footer.php", in any PHP includable function which requires mentioning of Real Paths.

Now if you use the above two real paths in the "include_once()" method in any of your sub-domains, you will be able to include these files (header & footer files) regardles of the sub-domain you use. This is how it is accomplished normally.

Hope it helps.

Knowledge Craving