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
redirect subdomain to a php file
Moderator: General Moderators
-
mostafa.fayyaz
- Forum Newbie
- Posts: 5
- Joined: Mon Jul 27, 2009 12:08 pm
Re: redirect subdomain to a php file
I've never done this myself, so I'm not entirely sure....but this may be worth a look.
-
mostafa.fayyaz
- Forum Newbie
- Posts: 5
- Joined: Mon Jul 27, 2009 12:08 pm
Re: redirect subdomain to a php file
i'm sure . i saw this code.jackpf wrote:I've never done this myself, so I'm not entirely sure....but this may be worth a look.
but i forget url
Re: redirect subdomain to a php file
Does it work?
-
mostafa.fayyaz
- Forum Newbie
- Posts: 5
- Joined: Mon Jul 27, 2009 12:08 pm
Re: redirect subdomain to a php file
this is a example :
but i don't know why this code doesn't work
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]
Re: redirect subdomain to a php file
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...
Sorry I can't be of more help...I'll have to leave this to someone else
All I can suggest is to search google for "subdomain rewrite" or something similiar...
- swhistlesoft
- Forum Newbie
- Posts: 9
- Joined: Fri Aug 14, 2009 10:53 pm
- Location: Ontario
Re: redirect subdomain to a php file
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]
# 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]