4

I know there is a lot of questions on here about this... but right now I feel like a deer stunned by oncoming headlights... I just don't know where to start and which option to choose.

My requirements are simple.

User goes to http://application.domain.com or http://www.application.domain.com and the real location of these files is http://www.domain.com/application

Obviously this needs to be done using wildcards so that any domain (even if it doesn't exist) triggers the rewrite.

I hope this makes sense to someone

EDIT: I should also mention I have added the wildcard A record to my DNS entries in Cpanel *.domain.com

Thanks

Tim

Tim
  • 3,091
  • 9
  • 48
  • 64

2 Answers2

3

I posted this question onto serverfault.com and icyrock solved it. Incase anyone else is wondering the answer given is here:

https://serverfault.com/questions/203780/troubleshooting-a-htaccess-wildcard-subdomain-rewrite/203804#203804

Tim

Community
  • 1
  • 1
Tim
  • 3,091
  • 9
  • 48
  • 64
1

Simplest way in .htaccess would be to put the following in an htaccess file as high up in the hierarchy as possible.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.application\.* [OR]
RewriteCond %{HTTP_HOST} ^application\.* [NC]
RewriteRule .* http://www.domain.com/application [L]
Qix - MONICA WAS MISTREATED
  • 14,451
  • 16
  • 82
  • 145
  • 1
    Thanks for posting your answer. How can I modify this so it uses wildcards so I dont have to create a new htaccess entry for each new subdomain? – Tim Nov 16 '10 at 21:51
  • Aha, that's a little different then. I would recommend you check out http://stackoverflow.com/questions/49500/apache-rewrite-based-on-subdomain -- The question is asking pretty much the same thing! – Qix - MONICA WAS MISTREATED Nov 16 '10 at 22:03
  • Close but theirs redirect... I need the subdomain.domain.com to stay intact in the URL bar... – Tim Nov 16 '10 at 22:19