htaccess Elite

.htaccess tutorial


All times are UTC [ DST ]





Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: www.username.site.com to www.site.com/test.php?user=username
PostPosted: 13 May 2008 23:16 
Offline

Joined: 13 May 2008 23:07
Posts: 3
Hello.
I'm needing some serious help in resolving a problem.
I need to create some "virtual subdomains" for a site.
So the structure would be like this:
I have site.com
and site.com/test.php?user=username
and I want that the "test.php" page, with the query string to be accessible from username.site.com.
I cannot create the subdomains from the cPanel.
So basically, the subdomain doesn't exist, but if a user enter the url: http://www.username.site.com i want to redirect him (silent) to http://www.site.com/test.php?user=username.
Please help me, cause I have tried all the examples from this forum that seemed to relate with my problem, but i still get a 404 error message.
Thanks,
John.


Top
 Profile  
 
 Post subject: Re: www.username.site.com to www.site.com/test.php?user=username
PostPosted: 14 May 2008 00:15 
Offline

Joined: 13 May 2008 23:07
Posts: 3
Hello again,
I have studied more this problem and I have another question: does the host that hosts my site must approve this qind of htaccess usage or I need a special setting from the host?
John.


Top
 Profile  
 
 Post subject: Re: www.username.site.com to www.site.com/test.php?user=username
PostPosted: 14 May 2008 06:43 
Offline

Joined: 13 May 2008 23:07
Posts: 3
I Have Found the ANSWER (Of course, without any of your help, guys, thanks for nothing ;-)

So, If anybody is interested, this problem has a dual-solving component:
First of all, the administrator of the server where the site is hosted must configure the httpd.conf to accept wildcard dns.
Then, u must write some code into the .htaccess file.
The code is as follows:


Code:
#start of code
Options +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.yoursite\.com$ [NC]
RewriteRule ^$ http://www.yoursite.com/dinamicpage.php?value=%1 [L]

#end of code


So if u want to have http://www.username.yoursite.com as a virtual subdomain redirect to yoursite.com/a-page.php?user=username, u must:
1. contact your admin host (the firm that is hosting your site) and ask them to allow you to have virtual subdomains (they must allow you to have wildcard dns, this is a setting that must be done in the httpd.conf file on the server)
2. write the code above inside the .htaccess file

Hope this post will help many users.
John.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: MSNbot Media, Yahoo [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB