I need help with htaccess file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
agriz
Forum Contributor
Posts: 106
Joined: Sun Nov 23, 2008 9:29 pm

I need help with htaccess file

Post 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...
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: I need help with htaccess file

Post 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.
agriz
Forum Contributor
Posts: 106
Joined: Sun Nov 23, 2008 9:29 pm

Re: I need help with htaccess file

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: I need help with htaccess file

Post 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.
agriz
Forum Contributor
Posts: 106
Joined: Sun Nov 23, 2008 9:29 pm

Re: I need help with htaccess file

Post 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
agriz
Forum Contributor
Posts: 106
Joined: Sun Nov 23, 2008 9:29 pm

Re: I need help with htaccess file

Post 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
Post Reply