.httacces and virtual subdomains

#1
[eluser]jurosik[/eluser]
hi folks, i need to use virtual subdomains and use it as a variable, like:
http://var.domain.tld would use /default controller
http://var.domain.tld/foo would use /foo controller
and so on..

i'm totaly lost in these .htaccess expressions Sad

please, is here anyone who could help? thx

#2
[eluser]jurosik[/eluser]
nobody? it's the same thing as on EveryBlock website:

http://sf.everyblock.com/

i was trying almost everything, but all i get was that 500 Internal Server Error Sad

#3
[eluser]brianw1975[/eluser]
I'm not really sure what you mean.... the example just shows the same subdomain

Quote:http://var.domain.tld would use /default controller
http://var.domain.tld/foo would use /foo controller

and the / and /foo are of typical codeigniter usage...

do you really mean you want to do something like:

Code:
http://(www.)domain.tld/ uses the default controller

http://bar.domain.tld/foo uses the foo controller and has bar as a variable passed to it via the GET string?

http://bar.domain.tld/ uses the default controller and has bar as a variable passed to it via the GET string

are any of those what you want?

#4
[eluser]t'mo[/eluser]
As a cheap hack to serve three domains (call them 'domain.com', 'domain1.com', 'domain2.com') from the same hosting account, I've recently added something like this to my root .htaccess file:

Code:
RewriteEngine on
RewriteCond   %{HTTP_HOST} domain1.com$
RewriteRule   .*           domain1_index.php           [L]
RewriteCond   %{HTTP_HOST} domain2.com$
RewriteRule   .*           domain2_index.php           [L]

All three domains resolve to the same IP address. Requests for the first domain go to index.html (or whatever I've set the default page in / to be). Then these entries in .htaccess are routing requests to the other domains according to the values of the HOST header. The requests for domain1.com are handled by domain1_index.php, likewise for domain2.com.

I'm not sure if it will work for sub-domains, but I'll be trying that soon, since I want 'test.domain1.com' and 'www.domain1.com' to be different.

#5
[eluser]jurosik[/eluser]
ok guys, let me better explain my problem.

i have site with structure like this:
Code:
domain.tld/uk/post/1

uk is country code for united kindom, and i want this code move to the subdomain. virtual subdomain, there is no real subdomain at all.
Code:
uk.domain.tld/post/1

this is my .htaccess for now, which gives me 500 Internal Server Error on uk.vzahranici.sk:
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On

    # get rid of www
    RewriteCond %{HTTP_HOST} ^www.vzahranici.sk
    RewriteRule (.*) http://vzahranici.sk/$1 [R=301,QSA,L]

    # virtual subdomain, but don't work
    RewriteCond %{HTTP_HOST} ^([a-z]+).vzahranici.sk [NC]
    RewriteRule ^(.*)$ /index.php/$1 [QSA,L]

    RewriteBase /CommunityRoute
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|images|css|javascript|photos|plugins|_sub|robots\.txt|favicon\.ico)
    RewriteRule ^(.*)$ /index.php/$1 [L]

</IfModule>

#6
[eluser]renownedmedia[/eluser]
I'm thinking this will require more than changing a .htaccess file... You might need to change DNS settings on the fly, with predefined subdomains being written to a config file, and this may be impossible on shared hosting.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.