1

I have the following htaccess.

Options +FollowSymlinks 
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^(www|m)\.DOMAIN\.com$
RewriteCond %{HTTP_HOST} ^([^\.]+).DOMAIN.com$
RewriteRule ^(.*)$ http://DOMAIN.com/index.php?id=%1 [NC,QSA,L,R=301]

The problem is that although it works I need it to still use the subdomain as the URL. So basically now I'm trying to rewrite DOMAIN.com/index.php?id=%1 back into SUDOMAIN.DOMAIN.com so the user sees the subdomain they requested on the address bar and not the http://domain.com/index.php?id=user

I'ver tried all sorts of things but always end up with some sort of infinite loop. Please help!


I already have a wildcard subdomain set up. In conjunction with the htaccess shown above. The submain doesn't stick, it rewrites itself into the long string shown above. But what im trying to do is get the url ro remain subdomain.domain.com unfortunately the link you posted does peretty much the same as what I have posted above, doesn't really seem to be able to get the sub-domain to stick.

Any ideas?

Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155

2 Answers2

0

You need to change your DNS settings before. (A record)

There is already an answer for that question.

Community
  • 1
  • 1
antyrat
  • 27,479
  • 9
  • 75
  • 76
0

Not sure if you figured it out yet, but your last line (I believe) should be this:

RewriteRule ^(.*)$ index.php?id=%1 [NC,QSA,L,R=301]

If that does not work try this:

RewriteRule (.*) index.php?id=%1 [NC,QSA,L,R=301]

No expert but I have subdomains working from some other code I found. Hope it helps.

Cosmin
  • 21,216
  • 5
  • 45
  • 60
ingage
  • 220
  • 2
  • 14