I save dynamic content and static content in different subdomains for my web application, but I recently found out that if directly called dynamic content can be viewed on my static subdomain (www.) Or not at all.
URL structure:
http(s)://(subdomain).(domain).(tld)/(static page) OR (direct/random hash) OR (secure/random hash)
All static content is accessible via "WWW", which leads to my SEO friendly domains, such as
http(s)://www.domain1.com/about http(s)://www.domain1.com/ http(s)://www.domain2.com/about http(s)://www.domain2.com/
While dynamic content viewed through a web application will be accessible from a domain such as
http(s)://dynamic1.domain1.com/direct/randomhash http(s)://dynamic2.domain1.com/direct/randomhash http(s)://dynamic1.domain2.com/direct/randomhash http(s)://dynamic2.domain2.com/direct/randomhash
This is my current .htaccess file
Rules for rewriting dynamic links, where the URI starts with secure or direct , as well as any file extensions in the index.php file.
Header set Connection keep-alive <IfModule mod_dir.c> DirectorySlash Off </IfModule> <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^index.php - [L] RewriteRule ^(secure|direct) /index.php [L] RewriteCond %{REQUEST_URI} !^/server-status RewriteCond %{REQUEST_URI} !^/public/cache RewriteRule !\.(png|gif|css|jpg|zip|js|html|htm|swf|ico|fon|ttf|otf|svg|woff|woff2|eot)$ /index.php [L] </IfModule>
This currently works, but my problem is that if the user simply changes the subdomain from the one used for dynamic content for the WWW, it will still work and will cause the dynamic content to be accessible from my fake SEO subdomain .
I hope that I can edit this RewriteRule ^(secure|direct) /index.php [L] rule so that it is excluded if there is an active www. domain www. or not a subdomain together, still working if the domain or subdomain is something else.
That is, the subdomain or domain will still be wildcards if the subdomain is www.
I assume that I need to add %{HTTP_HOST} to RewriteRule ^(secure|direct) /index.php [L] and use a regex to resolve any additional domain, domain and tld, but I'm not sure how to exclude if An HTTP host starts with www. or not a subdomain at all.
My ultimate goal is that the secure and direct paths cannot be viewed using www. or without a subdomain when working with any other subdomain / domain.