我需要重写以下网址:
mydomain.com/dashboard/index.php?user=john-dow
到
john-dow.mydomain.com/dashboard/index.php
因此,我想获取查询字符串值并将其放置在域的开头,后跟一个点。目标是创建自定义的用户url,因此对用户而言看起来非常友好。但是实际上,我不知道该怎么办。.htaccess有可能吗?如果是,怎么办?
用于您的dashboard/.htaccess
:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(.+)\.mydomain\.com$ [NC]
RewriteCond %{QUERY_STRING} ^user=(.+)$
RewriteRule ^index\.php$ http://%1.mydomain.com/dashboard/index.php? [R,L]
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句