Page 1 of 1
redirect subdomain to a php file
Posted: Fri Aug 14, 2009 3:53 pm
by mostafa.fayyaz
hello !
i want to redirect all subdomains to show.php.
for example :
test.mydomain.info
to
show.php?url=test
i want to use .htaccess file . but it does't work
plase help me
Re: redirect subdomain to a php file
Posted: Fri Aug 14, 2009 4:00 pm
by jackpf
I've never done this myself, so I'm not entirely sure....but
this may be worth a look.
Re: redirect subdomain to a php file
Posted: Fri Aug 14, 2009 4:05 pm
by mostafa.fayyaz
jackpf wrote:I've never done this myself, so I'm not entirely sure....but
this may be worth a look.
i'm sure . i saw this code.
but i forget url
Re: redirect subdomain to a php file
Posted: Fri Aug 14, 2009 4:08 pm
by jackpf
Does it work?
Re: redirect subdomain to a php file
Posted: Fri Aug 14, 2009 4:11 pm
by mostafa.fayyaz
this is a example :
Code: Select all
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9]+)/?(.*)$ go.php?s=$1&file=$2 [L,QSA]
but i don't know why this code doesn't work
Re: redirect subdomain to a php file
Posted: Fri Aug 14, 2009 6:15 pm
by jackpf
I have to admit I'm not sure. As I said, I've never actually done this...I just thought that link would be useful.
Sorry I can't be of more help...I'll have to leave this to someone else

Sorry
All I can suggest is to search google for "subdomain rewrite" or something similiar...
Re: redirect subdomain to a php file
Posted: Fri Aug 14, 2009 11:41 pm
by swhistlesoft
This might be what you are looking for.
# if requested subdomain is not "www"
rewriteCond %{HTTP_HOST} !^(www\.)?example\.com [NC]
# and we have not already rewritten this request to the subdomain's subfolder
rewriteCond %{THE_REQUEST} !/folder/.
# extract requested subdomain to %2
rewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.example\.com
# rewrite the request to the subdomain's subfolder
rewriteRule (.*) /folder/%2/$1 [L]