TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-17-2007, 08:35 PM   #1 (permalink)
The Contributor
 
Join Date: Dec 2007
Posts: 31
Thanks: 0
TerrorRonin is on a distinguished road
Smile 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/
TerrorRonin is offline  
Reply With Quote
Old 12-17-2007, 08:39 PM   #2 (permalink)
Jay
The Contributor
Good Samaritan 
 
Join Date: Dec 2007
Posts: 60
Thanks: 5
Jay is on a distinguished road
Default

mod_rewrite is not a substitute for Virtual Hosts ;)

Read: http://httpd.apache.org/docs/1.3/vhosts/
Jay is offline  
Reply With Quote
Old 12-17-2007, 08:54 PM   #3 (permalink)
The Contributor
 
Join Date: Dec 2007
Posts: 31
Thanks: 0
TerrorRonin is on a distinguished road
Default

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..
TerrorRonin is offline  
Reply With Quote
Old 12-17-2007, 09:49 PM   #4 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

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.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 12-17-2007, 10:03 PM   #5 (permalink)
The Acquainted
 
wGEric's Avatar
 
Join Date: Nov 2007
Posts: 166
Thanks: 0
wGEric is on a distinguished road
Default

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.
__________________
Eric
wGEric is offline  
Reply With Quote
Old 12-17-2007, 11:38 PM   #6 (permalink)
The Contributor
Upcoming Programmer 
 
Matt83's Avatar
 
Join Date: Oct 2007
Location: Argentina
Posts: 72
Thanks: 18
Matt83 is on a distinguished road
Default

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]
__________________
http://www.mattvarone.com
Matt83 is offline  
Reply With Quote
Old 12-18-2007, 01:17 AM   #7 (permalink)
The Contributor
 
Join Date: Dec 2007
Posts: 31
Thanks: 0
TerrorRonin is on a distinguished road
Default

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..?
TerrorRonin is offline  
Reply With Quote
Old 12-18-2007, 09:18 AM   #8 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

as i said i think its a dns issue
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 12-18-2007, 01:51 PM   #9 (permalink)
The Contributor
Upcoming Programmer 
 
Matt83's Avatar
 
Join Date: Oct 2007
Location: Argentina
Posts: 72
Thanks: 18
Matt83 is on a distinguished road
Default

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
__________________
http://www.mattvarone.com
Matt83 is offline  
Reply With Quote
Old 12-18-2007, 01:56 PM   #10 (permalink)
The Contributor
Upcoming Programmer 
 
Matt83's Avatar
 
Join Date: Oct 2007
Location: Argentina
Posts: 72
Thanks: 18
Matt83 is on a distinguished road
Default

Quote:
Originally Posted by sketchMedia View Post
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
__________________
http://www.mattvarone.com
Matt83 is offline  
Reply With Quote
Old 12-18-2007, 04:02 PM   #11 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

You could do a Wildcard DNS, which allows for this easily.
Orc is offline  
Reply With Quote
Old 12-19-2007, 09:21 AM   #12 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

that was exaclty what my thoughts where, let us know how you get on :)
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 12-24-2007, 07:20 PM   #13 (permalink)
The Contributor
 
Join Date: Dec 2007
Posts: 31
Thanks: 0
TerrorRonin is on a distinguished road
Default

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.
TerrorRonin is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 11:28 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design