How can this be done??? [ a hard one? ]

Topics: Developer Forum, User Forum
Aug 17, 2008 at 8:36 PM
Look at the example below: >> >> leave as is >>

the first rule is if there is no prefix subdomain, add "www."
the second rule is if subdomain exists, move it to the parameter.
and third, and the tricky - is if the subdomain is "www" don't touch the url, dont rewrite it!

Please advice :-) Thanks!
Aug 18, 2008 at 10:58 AM

so long as your dns is setup to accept [anything] then have a look at this, the regex should be fairly similar.
Aug 21, 2008 at 12:54 PM

this might be close to what you want:

  # do nothing with any URLs that uses www prefix as the hostname 
  RewriteCond %{SERVER_NAME} ^(www\.)$
  RewriteRule ^/(.*)$  -   [L]

  # for URLs that use the bare domain, redirect to the www host
  RewriteCond %{SERVER_NAME} ^$
  RewriteRule ^/(.*)$$1   [R]

  # for other URLs, redirect and rewrite.  Handle the case with no query string:
  RewriteCond %{SERVER_NAME} ^(.+\.)$
  RewriteRule ^/([^?]*)$$1?q=%1  [R]

  # handle the case with a query string
  RewriteCond %{SERVER_NAME} ^(.+\.)$
  RewriteRule ^/(.*)$$1&q=%1  [R]