Forum Moderators: phranque

Message Too Old, No Replies

Subdomain mod rewrite

subdomain mod rewrite

         

anil34

12:42 pm on Feb 27, 2005 (gmt 0)

10+ Year Member



Hi

I am sure this question has been addressed, but I did not have much luck with it. I am trying to create a site similar to craigslist. Craigslist.org is a separate site that I found on internet. I am trying to start a site similar to that site. So I want to do what that person has done as far as mod-rewrite goes.

(substituted craigslist for 'mydomain')

washingtondc.mydomain.org/
austin.mydomain.org/stp
boston.mydomain.org/stp/61073929.html

obviously, these are just examples, the 'washingtondc', 'stp', '6107929' could be anything.

So if my site is mydomain.com, I would like to access by

mydomain.com/city.php?city=washingtondc
mydomain.com/categ.php?city=austin&categ=stp
mydomain.com/ad.php?city=boston&categ=stp&ad=61073929

Could someone please suggest the mod rewrite rules.

I think I need to mention that this domain is a sudomain to my main domain, domain.com meaning that it is the same url as mydomain.domain.com. The hosting provider allows subdomain
if i have have /home/username/pubic_html/mydomain.

Everyone will be accessing it via mydomain.com or www.mydomain.com. I am assuming that I will have to put .htaccess file in my subdomain root directory.

Thanks for everybody's time.

Anil

zyron

9:33 pm on Feb 27, 2005 (gmt 0)

10+ Year Member



I'll give it a try:

mydomain.com/city.php?city=washingtondc

RewriteRule city=(.+) [$1.mydomain.com...] [L,R]

Good Luck!

anil34

11:47 am on Feb 28, 2005 (gmt 0)

10+ Year Member



That does not work. :(

sitz

2:07 am on Mar 2, 2005 (gmt 0)

10+ Year Member



I'm a little confused. What are you trying to accomplish here, turning this client request:

mydomain.com/ad.php?city=boston&categ=stp&ad=61073929

...into this:

boston.mydomain.com/stp/61073929.html

Or turning this client request:

boston.mydomain.com/stp/61073929.html

...into this:

mydomain.com/ad.php?city=boston&categ=stp&ad=61073929

anil34

11:57 pm on Mar 2, 2005 (gmt 0)

10+ Year Member



if someobody makes a request of

boston.mydomain.com/stp/61073929.html on my server
(my URL will look like the one above)

it actually gets gets executed via this php

mydomain.com/ad.php?city=boston&categ=stp&ad=61073929

zyron

11:15 am on Mar 3, 2005 (gmt 0)

10+ Year Member



I'll give it another try..

After some search, and one test.
it seems like this

RewriteRule ^(.*)$ /?$1

only rewrite what is after the domain.

Meaning that you cannot use it for subdomain.

Sorry.

A feature I would like myself, so please correct me if I'm wrong.

A php script would solve your problem though..

Zyron

>if someobody makes a request of
>boston.mydomain.com/stp/61073929.html on my server
>(my URL will look like the one above)

>it actually gets gets executed via this php

>mydomain.com/ad.php?city=boston&categ=stp&ad=61073929

anil34

3:41 pm on Mar 3, 2005 (gmt 0)

10+ Year Member



Hi, Mike at another site is trying to help me out. lets see if that works

forums.searchenginewatch.com/showthread.php?p=37293#post37293

zyron

8:08 pm on Mar 6, 2005 (gmt 0)

10+ Year Member



hello!

I want to thank you for referring me to the other forum, that suggested it is possible to do this.

The code itself didn't help me much, but after doing some searching and I managed to solve my problem.

This code read the subdomain and pass it on to a script:

RewriteCond %{HTTP_HOST} ^(www\.)?([^.]*)(.*)domain.com$
RewriteCond %{REQUEST_URI}!^/static/*
RewriteRule ^/(.*)$ /index.php?q=$1&firstsubdomain=%2&moresubdomain=%3 [L,QSA]

works with:

Www.ES.domain.com
ES.domain.com
domain.com

And

Www.first domain.more domains.domain.com/q_string

I hope this is enough to solve your problem, let me know if there's something you cannot figure out!