Dynamic subdomain problem

hi, im using this rewrite to use dynamic subdomains

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example.com
RewriteCond %{HTTP_HOST} ([^.]+)\.example.com
RewriteRule ^(.*)$ /var/www/hosts/example.com/httpdocs/index.php?code=%1

which works great, i can even use the subdomain as a php variable. THe only problem im having is including external css and js files (which are in the root of the site since these subdomains are dynamic)

ive even tried doing this

<link rel=“stylesheet” href=“https://www.example.com/css/style.css”>

but still not working which i found kind of weird.

any suggestions?

thanks in advance


Suggestions? Yes.

  1. Escape all dot charaters in the test of {HTTP_HOST} and make your regex case INSENSITIVE with a No Case flag.

  2. Use an absolute link to your webspace, not to your physical location on the server.

Saying that, though, your “missing support files” are easily resolved - with the code provided in my signature’s tutorial Article.



thanks dk, im actually using this for all the subdomain variables

(!preg_match(“/[1]{1,15}$/”, $page)) {die(“error, not valid”); exit();}}

so im hoping that will make things secure enough… is there something else i could do?

also i figured out my original problem by simply changing https to http

  1. a-zA-Z0-9_ ↩︎