Page 1 of 1

I need help with htaccess file

Posted: Mon Mar 02, 2009 4:39 am
by agriz
Dear friends,

I have a domain which contain several sub domains.

What i want is, if user types

http://subdomain.domain.com
(The url should stay like this)
But it should execute the root's index page with a query string
http://domain.com/index.php?query=subdomain

Since i am not strong enough in .htaccess, can you help me with this?

Thanks in advance...

Re: I need help with htaccess file

Posted: Mon Mar 02, 2009 5:56 am
by requinix
As long as the domain.com server is handling subdomain.domain.com's requests then you can use mod_rewrite to do that.
Meaning http://subdomain.domain.com takes you to the same content as http://domain.com.

Otherwise I'm not too sure it's possible.

Re: I need help with htaccess file

Posted: Mon Mar 02, 2009 6:28 am
by agriz
Hi,

If my domain is handling the subdomain, then is it possible?

I tried some rewrite conditions, but i got error which did not even load my website..

Thanks for your reply.

Re: I need help with htaccess file

Posted: Mon Mar 02, 2009 6:58 am
by requinix
agriz wrote:If my domain is handling the subdomain, then is it possible?
If what I said is true then yes, it should be possible.

You need RewriteCond since that's the only way to know the requested subdomain.

Code: Select all

RewriteCond %{HTTP_HOST} ^(.+)\.domain\.com$
RewriteRule ^/?$ /index.php?query=%1
That Rule may not be exactly what you want: it only rewrites a "blank" request.

Re: I need help with htaccess file

Posted: Mon Mar 02, 2009 7:06 am
by agriz
Hi tasairis,

Thank you for your help.

one general question. In my server, I just created a folder called live.

So we can access it both ways.

http://live.agriz.in or http://agriz.in/live

This live folder contains nothing.

So http://live.agriz.in gives
Forbidden
You don't have permission to access / on this server.

What does it mean?

Thanks

Re: I need help with htaccess file

Posted: Mon Mar 02, 2009 7:09 am
by agriz
Actually

I used user htaccess code. But it did not call the roots index.php

Other subdomains are working with their own data. But none of them call the index.php of root

Is there any problem with my domain?

Thanks