php - creating subdomain with .htaccess -


i not familiar .htaccess . trying create .htaccess file redirect subdomain portfolio.

for example : bob.example.com ,

which redirect bob portfolio. in background script executed following way.

example.com/portfolio.php?id=bob 

i have written following .htaccess

rewritecond %{http_host} !^([w]{3,3}[.]{1,1}){0,1}example.com$ rewritecond %{http_host} ^([0-9a-za-z-]*)[.]example.com$ rewriterule ^.*$ http://example.com/portfolio/index.php?id=%1 [r,l] 

issue , if use bob.example.com redirect example.com/portfolio/index.php?id=bob

if use bob.example.com must open portfolio direct , instead of redirection

alright , managed self create

rewriterule ^$ portfolio/index.php?id=%1 [nc,l] 

above statement works ! thank !

try this:

rewritecond %{http_host} ^([a-z0-9]+)\.domain\.com [nc] rewriterule .* http://domain.com/portfolio/index.php?id=%1 [qsa,r=301,l] 

although wouldn't recommend this. if you're working kind of mvc framework i'm sure it's routing components can accomplish you.


Comments

Popular posts from this blog

Java sticky instances of class com.mysql.jdbc.Field aggregating -