TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Help with a mod_rewrite (http://www.talkphp.com/general/1760-help-mod_rewrite.html)

TerrorRonin 12-17-2007 08:35 PM

Help with a mod_rewrite
 
What do I need to setup within my .htaccess so that *1.domain.com shows the content of domain.com/sites/*1/ without redirecting? Please note, *1 means any possible combination, would redirect to that combinations subdomain..

Some examples:
http://test.domain.com/ = http://domain.com/sites/test/
http://new.domain.com/ = http://domain.com/sites/new/

Jay 12-17-2007 08:39 PM

mod_rewrite is not a substitute for Virtual Hosts ;)

Read: http://httpd.apache.org/docs/1.3/vhosts/

TerrorRonin 12-17-2007 08:54 PM

This is going to be for a free website generator.. meaning they type in the subdomain they want, and then a cms system is copied into that select folder, and then they have free hosting..

So I don't know what you're talking about.. but it has nothing to do with more than one machine..

sketchMedia 12-17-2007 09:49 PM

hmm not sure m8, you could i suppose use htaccess to do it, but wouldnt you have to change the dns entries? otherwise its not going to resolve an address? sorry m8 i dunno, i know jack about apache and the mod_rewrite engine.

wGEric 12-17-2007 10:03 PM

Code:

RewriteRule http://(.*)\.domain\.com http://domain.com/site/$1
I'm not sure if that will work on the domain though. I've only worked with domains in RewriteCond.

Matt83 12-17-2007 11:38 PM

you mean something like this?

Quote:

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com$ [NC]
RewriteRule ^$ /sites/%1 [QSA,L]

TerrorRonin 12-18-2007 01:17 AM

It doesn't seem to work..

http://test.clanassist.com/
http://www.clanassist.com/sites/test

I did replace `domain` with clanassist... so I dont think that's the issue.. any other recommendations..?

sketchMedia 12-18-2007 09:18 AM

as i said i think its a dns issue

Matt83 12-18-2007 01:51 PM

Quote:

Originally Posted by ;6808
It doesn't seem to work..

http://test.clanassist.com/
http://www.clanassist.com/sites/test

I did replace `domain` with clanassist... so I dont think that's the issue.. any other recommendations..?

Sorry TerrorRonin, i typed that on a hurry, here is the corrected code:

Code:

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} !^www\.clanassist\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.clanassist\.com$ [NC]
RewriteRule ^([^/]+)$ /sites/%1/ [QSA,L]

Remember that for this to work you should create a sites folder and ( for example ) a test folder in your domain, ( add an index.html if you want to see something )

cheers

Matt83 12-18-2007 01:56 PM

Quote:

Originally Posted by sketchMedia (Post 6811)
as i said i think its a dns issue

Not really, i have done this many times via .htaccess without extra dns configuration. Mod rewrite is very powerful :-)

Orc 12-18-2007 04:02 PM

You could do a Wildcard DNS, which allows for this easily.

sketchMedia 12-19-2007 09:21 AM

that was exaclty what my thoughts where, let us know how you get on :)

TerrorRonin 12-24-2007 07:20 PM

Alright.. so your code worked.. but one slight problem..

test.clanassist.com/README.txt

That won't show the file that it should.. or any of the files don't show.. So is there any way to make it so the files DO show?

Such as..
Images won't link the way that it's set up, and people can't view pages :(..

So.. any help for having the previous part of the URL resolve as well?

Edit:
And by the way, this does require a DNS Entry
* | 14400 | IN | A | 74.52.***.***

That's what I put.. by my IP still shows.. just not going to post it here.


All times are GMT. The time now is 04:58 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0