0

Within my custom built PHP web applicaion I have multiple domains pointing to the /root/abc folder. IE: domain.com; mobile.domain.com, admin.domain.com and so on.

The way my CMS is setup the index.php file in /root/abc loads different index.php files that are stored on sub directories like /root/abc/mobile, /root/abc/admin, etc.. depending on the subdomain names.

I am having different .htacess files at /root/abc, /root/abc/mobile and /root/abc/admin respective to sub domains.

At this point I want to cache files from domain.com and mobile.domain.com but the cache should not work for admin.domain.com, and other subdomain.domain.com

Firstly, .htaccess file on /root/abc loads and then index.php file on /root/abc loads too. This loaded index.php on root loads different folders varying on the sub domain and other properites respective to subdomain.domain.com. The sub domain name is dynamic meaning the subdomain names and folder directories changes.

1.. Even if I use HTML meta tags to clear cache it does not work. Can you explain this behavior?

2.. How to load .htaccess files dynamically depending on the subdomain name?

Yellow and Red
  • 695
  • 9
  • 31
  • Here's a question about HTML meta tags and caching control, http://stackoverflow.com/q/1341089/1741542 – Olaf Dietsche Jul 05 '16 at 16:37
  • Thank you Olaf, That was helpful for Meta Tags, the bad thing is it is not working on older IE version. – Yellow and Red Jul 06 '16 at 06:11
  • How to load .htaccess files dynamically depending on the subdomain name using .htaccess itslef? – Yellow and Red Jul 06 '16 at 06:12
  • 1
    .htaccess files are loaded unconditionally, based on the appropriate directory alone. If you want configuration based on the domain, you must do so with `If`, `RewriteCond`, or - better yet - with a virtual host configuration file. – Olaf Dietsche Jul 06 '16 at 07:40

1 Answers1

1

An .htaccess file applies to the directory it is in an all its subdirectories. Only the filesystem matters for this.

Even if I use HTML meta tags to clear cache it does not work.

Meta tags for cache control are a joke and real HTTP headers trump them anyway.


Avoid .htaccess:

You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance.

The Apache HTTPD manual

You have your subdomains set up in the Apache configuration. Set your cache control directives there, in the <VirtualHost> blocks instead.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • That was quick and this helped me to understand about HTTPD. After reading your answer I went through Godaddy and I found out that I do not have access to edit the same. Is there any way to do the same with .htaccess inherting .htaccess depending on the directories – Yellow and Red Jul 05 '16 at 15:42