Forum Moderators: phranque
Here's what I have in .htaccess, which is under my root directory:
RewriteEngine on
RewriteCond %{HTTP_HOST}!^(www\.)?thesitename\.com [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.thesitename\.com [NC]
RewriteRule .* /test.php?name=%1 [L]
What I need to do is like this:
If www.thesitename.com or thesitename.com is entered, doing nothing.
If abc.thesitename.com, 123.thesitename.com, etc. are entered, the users will be redirected to the test.php page under the root, where I'll parse the subdomain name using name=%1.
After I modified the .htaccess file and loaded the test.php to the site, I got The page cannot be displayed page with Cannot find server or DNS Error if I type [aaa.thesitename.com....] But if I only type aaa.thesitename.com, I was redirected to the error page from www.overture.com that I've no connection to.
I've no idea what is happening here. Please help. Thanks.
Welcome to WebmasterWorld [webmasterworld.com]!
Your code looks fine to me.
The symptoms you describe lead me to the conclusion that your DNS is not set up for the subdomains you are requesting.
The Overture bit is a 'little trick' played by some ISPs and/or Browser Helper Objects as a promotion for whatever search engine they redirect you to. Run AdAware and SpyBot Search & Destroy (both freeware) if you haven't done so already.
You will need to define an A record for each subdomain you intend to use, or you will need to enable "wild-card" DNS - Not all hosting companies will allow this.
Basically, you'll need to add a record to your zone file that looks like this (note that trailing period!) :
abc.thesitename.com. IN A 192.168.0.172
Jim
Thanks for the reply. I checked the hosting site and the only place is close to the setup of DNS is a list of DNS records, like www, ftp, etc. When I tried to add a new DNS record for subdomain, it asked for name server info.
Well, I'm not familiar at all with the zone file you mentioned. I'd appreciate it if you could give more detailed info on the process of setting up wild-card DNS in the Zone file. Thanks again and Happy New Year!
Setups differ among hosting providers -- to the point where the most I can offer is what I posted above. You may wish to contact your hosting provider, or your Name services provider if different.
They should be able to tell you how to set up your new subdomains without negatively affecting your site.
Jim
http://helpcenter.example.com
to
http://www.example.com/helpcenter.html
I wrote this on .htaccess file
RewriteEngine on
RewriteCond %{HTTP_HOST} ^helpcenter.example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.helpcenter.example.com$
RewriteRule ^(.*)$ http://www.example.com/helpcenter.html [R=301,L]
... and put it under /public_html/helpcenter folder.
IT DID NOT WORK ~~~
I have been trying since this morning...
This is the most useful resource I found:
http://help.powweb.com/tutorials/htaccess/subdomain.php
Hope you have solved your problme :)
[edited by: jdMorgan at 9:59 pm (utc) on Feb. 4, 2004]
[edit reason] Removed specific URLs. Please see TOS [/edit]
You did not specify how "it didn't work," but this might work better:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?helpcenter\.example\.com
RewriteRule .* http://www.example.com/helpcenter.html [R=301,L]
Ref: Introduction to mod_rewrite [webmasterworld.com]
Jim