Friday 15 May 2015

.htaccess - htaccess multiple subdomain to multiple url's -


I'm not sure how this is the best way.

We have many sellers here and each subdomain is:

  http://johndoe.mydomain.com   

However, We have all the profiles available on the site, which are available in IE:

  http://mydomain.com/sales/index.php?person=jdoe   < P> We have around 15 sales, and in the end I will have time to enter the new profile as it is scripted to enter. For now, if I need, I can edit the .htaccess file. I have seen that all examples redirect to a specific domain or subfolder.   

You place it in the .htaccess file:

  rewrite angle% {REQUEST_FILENAME}! -f reuse% {HTTP_HOST} ^ (. +) \. Mydomain \ .com $ [nc] rewrite rule / / $ / index.php? Person =% 1 [P, L, QSA]   

This would be more common:

  rewrite% {REQUEST_FILENAME}! -F RewriteCond% {HTTP_HOST} ^ (. +) \. Mydomain \ .com $ [nc] rewrite rule ^. * $ /index.php?person=%1&page=$0 [P, L, QSA]   

The problem can also be resolved at the PHP level: < Pre> $ domain_array = explosion (".", $ _SERVER ["HTTP_HOST"]); $ Person = $ domain_array [0];

or:

  if (preg_match ("@ ^ (. +). Mydomain \ .com $ @", $ _SERVER ["HTTP_HOST" ], $ Match)) {$ person = $ match [1]; } And {$ person = ""; }    

No comments:

Post a Comment