robert_gsfame Posted March 3, 2010 Share Posted March 3, 2010 I really confused with this....i wish to have a subdomain for my user but i always manage subdomain by typing *.domain.com inside my cpanel which is always redirect me to index.php Is it possible to redirect all subdomain to http://www.domainname.com/page1.php instead of index.php??? Would be appreciate if you can give me brief explanation thx so much!! Quote Link to comment Share on other sites More sharing options...
inversesoft123 Posted March 3, 2010 Share Posted March 3, 2010 method 1: you have to set wildcard subdomains to another directory rather than public_html [Root] eg . you can set it /public_html/subdomains method 2: If because of some reasons you are using public_html then $exp = explode(".", $_SERVER['HTTP_HOST']) ; if($exp[0]== "www" || $exp[0] == "WWW") { $username = $exp[1]; if($username != "yourTLD") //your main domain { header("Location:page1.php"); } } else { $username = $exp[0]; if($username != "yourTLD") //your main domain { header("Location:page1.php"); } } Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted March 3, 2010 Author Share Posted March 3, 2010 I use the second method but i have this error when using mozilla The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete. * This problem can sometimes be caused by disabling or refusing to accept cookies. Quote Link to comment Share on other sites More sharing options...
jtgraphic Posted March 3, 2010 Share Posted March 3, 2010 That means you're redirecting in a loop. I'd go back and be sure you have the URLs correct. Also, try using absolute paths to the new URL. Quote Link to comment Share on other sites More sharing options...
inversesoft123 Posted March 3, 2010 Share Posted March 3, 2010 are you adding this code in header.inc.php ? Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted March 3, 2010 Author Share Posted March 3, 2010 yeah you're right i got wrongly loop!! thanks SO MUCH for all helps both of you're really great!! One more thing, i redirect the page to http://www.domain.com/page1.php?user=$subdomain when subdomain was typed on url Can i have only subdomain.domain.com typed instead of subdomain.domain.com/page1.php?user=$subdomain using .htaccess I have this but i don't think it's correct as i am just new on this.. <IfModule mod_rewrite.c> Options +FollowSymLinks Options +Indexes RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !www.domain.com$ [NC] RewriteCond %{HTTP_HOST} ^([a-z0-9-]+).domain.com [NC] RewriteRule (.*) page1.php?user=%1 [L] RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).domain.com [NC] RewriteRule (.*) page1.php?user=%2 [L] </IfModule> Quote Link to comment Share on other sites More sharing options...
inversesoft123 Posted March 3, 2010 Share Posted March 3, 2010 http://www.mydomain.com/page1.php?user=$subdomain This happens only in case if you have another wildcard redirection rule in .htaccess or some kind of url shortner redirection rule. Remove that first for subdomain.domain.com i.e if you dont want page1.php in url you need to set wildcard subdomain to directory as i stated above method1. Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted March 3, 2010 Author Share Posted March 3, 2010 <IfModule mod_rewrite.c> Options +FollowSymLinks Options +Indexes RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !www.domain.com$ [NC] RewriteCond %{HTTP_HOST} ^([a-z0-9-]+).domain.com [NC] RewriteRule (.*) page1.php?user=%1 [L] </IfModule> i have modified some script n it works but image that is stored inside my folder didn't appear Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted March 3, 2010 Author Share Posted March 3, 2010 okay finally everything was solved thx for your help!! inversoft Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.