Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 php 代码中,我需要将所有虚拟子域重定向到与参数具有相同子域的页面。
例如,重定向自:
anytext.mydomain.com
至 :
mydomain.com/example.php?text="anytext"
我怎么能用htaccess文件做到这一点?
试试这个,它肯定会帮助你:
# .htaccess Options +FollowSymLinks RewriteBase / RewriteCond %{HTTP_HOST} !^www.your-domain-name.com [NC] RewriteCond %{HTTP_HOST} ^(www.)?([^.]+).your-domain-name.com$ [NC] RewriteRule ^([^.]+)$ /some_file.php/$1?subdomain=%2 [L,QSA]