Is it possible to do this type redirection by .htaccess only:
from: http://domain.com/directory.php?ref=sub
to: http://sub.domain.com/directory.php
If not, what do I need for that?
检查教程
http://blog.gwebtools.com/apache-htaccess-subdomain-redirect-rules/
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ([a-z0-9-]+)/? http://$1.domain.com [R=301,NC,L]
用您的域名替换“domain.com”的两个实例。