phpBB SEO
Boards
Directory  
SEO  
Downloads
  phpBB SEO : Search Engine Optimization, Directory, Forums  
Index
Forums
Annuaire
Référencement
Télécharger
 
  Search Rechercher
    Register
Username :  Password :  Log me on automatically each visit  
S'enregistrer  
 
   
subdomain rewrite problem - semi dynamic

 
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » Apache mod Rewrite
::  
Author Message
anotherexcuse



Joined: 30 Apr 2008
Posts: 1

subdomain rewrite problem - semi dynamicPosted: Wed Apr 30, 2008 5:06 pm    Post subject: subdomain rewrite problem - semi dynamic

Hi

I wonder if anyone can stear me in the right direction with this one?

I have a website with different regions that a user sellects.

What I am trying to do is set up a dynamic subdomain rewite with .htaccess.

My server does support wilcard dns.

For eaxample:

If a user wants the Birmingham page, they would go to:
www.mysite.com/index.php?view=main&cityid=2
(where 2 is the city id for Birmingham)

Ideally i would want the user to go to birgmingham.mysite.com

I have been playing with variations of this that I found in this forum:

Code:
RewriteCond %{HTTP_HOST} !^www\.mysite.com
RewriteCond %{HTTP_HOST} birmingham\.mysite.com
RewriteRule ^(.*)$ /srv/www/vhosts/mysite.com/httpdocs/index.php?view=main&cityid=1


But can't seem to get it to work.

I have about 90 cities to add so I guess i would need to write 90 rules?
Or maybe there is a way i could index the cities and city id numbers?

I'm struggling with this.

If anyone can help?

Many Thanks

M
Back to top
SeO
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 15 Mar 2006
Posts: 2461

subdomain rewrite problem - semi dynamicPosted: Fri May 02, 2008 12:39 pm    Post subject: Re: subdomain rewrite problem - semi dynamic

Well it's a bit more complicated than this, because you as well need to configure the vhost to allow and manage dynamic subdomains.

A nice way to do it is if you have access to the vhost-alias Apache module. If so you could use something like this in your VHOST :

Code:
<VirtualHost *>
ServerName example.com
ServerAlias *.example.com
VirtualDocumentRoot /var/www/$1
</VirtualHost>


This way sub.example.com would go in www/sub/ where www/ would be example.com (the main domain's root) in your server file-system.

With this you could then play with mod_rewrite to catch the sub domain through the path, (sub/) which does not necessarily need to exist physically (thanks to mod rewrite again), and pass it to the php script you want.

_________________
Back to top
Display posts from previous:   
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » Apache mod Rewrite
Page 1 of 1

Navigation Similar Topics

Jump to: