Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

subdomain using .htaccess


  • Please log in to reply
5 replies to this topic

#1 fkabeer

fkabeer

    CC Lurker

  • Just Joined
  • Pip
  • 3 posts

Posted 11 August 2008 - 03:10 AM

My problem is apache related:
I want 2 do translate
[value].domain.com to domain.com/index.php?id=[value]

i found this

<IfModule mod_rewrite.c>
   Options +FollowSymLinks
   Options +Indexes
   RewriteEngine On
   RewriteBase /
   RewriteCond %{HTTP_HOST} !^www\.domain.com
   RewriteCond %{HTTP_HOST} ([^.]+)\.domain.com
RewriteRule ^(.*)$ /?id=%1
</IfModule>
it isn't working . it event doesn't browse the page

Edited by Jaan, 12 August 2008 - 12:47 AM.

  • 0

#2 Guest_Jordan_*

Guest_Jordan_*
  • Guest

Posted 11 August 2008 - 04:37 AM

You have to add the subdomain as a subdomain first so that it is added to DNS. Make the location the point to the root dir of domain.com/.

You can then use something like you have above. Here is what we use for the CodeCall blog:

RewriteCond %{HTTP_HOST} ^blog\.codecall\.net$ [NC]
RewriteRule ^$ /index.php?option=com_myblog [L]

RewriteCond %{HTTP_HOST} ^blog\.codecall\.net$ [NC]
# Ignore requests to existing files (index.php).
RewriteCond %{SCRIPT_FILENAME} !-f
# Ignore requests to existing directories.
RewriteCond %{SCRIPT_FILENAME} !-d
# Match the URI, pass it on.
RewriteRule ^([^/]+)/?$ /index.php?option=com_myblog&task=$1 [L]

  • 0

#3 fkabeer

fkabeer

    CC Lurker

  • Just Joined
  • Pip
  • 3 posts

Posted 11 August 2008 - 05:08 AM

i believe there is some mis understanding between us the [value] here is "user driven" let say "username" and i want it to recieve it in $_GET variable e.g,
xyz.domain.com to domain.com/?name=xyz
echo "Welcome Mr. " . $_GET[name]; output Welcome Mr. xyz
location redirection is a piece of cake and its option is available in cpanel
any help.
  • 0

#4 Guest_Jordan_*

Guest_Jordan_*
  • Guest

Posted 11 August 2008 - 05:09 AM

I see, you will need to setup your httpd.conf file to point *.yourdomain.com to your root directory (yourdomain.com). Otherwise this will not work.
  • 0

#5 fkabeer

fkabeer

    CC Lurker

  • Just Joined
  • Pip
  • 3 posts

Posted 12 August 2008 - 08:57 PM

where can i find "httpd.conf" in cpanel, i looked for it but i haven't found it
  • 0

#6 Guest_Jordan_*

Guest_Jordan_*
  • Guest

Posted 13 August 2008 - 03:41 AM

In Cpanel I believe you can add *.yourdomain.com as a subdomain pointing to your root. If not, contact your server administratior(s). They should be able to help you with that.
  • 0




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download