我想要做的是能够将username.domain.com之类的东西指向index.php?url=username。我一直在Google/StackOveflow上浏览,但没有找到任何对我有益的东西。
诚挚的问候。
发布于 2012-10-23 11:09:00
将这些规则添加到文档根目录下的htaccess文件中:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain.com$ [NC]
RewriteCond %{REQUEST_URI} !index.php
RewriteRule ^ /index.php?url=%1 [L]第一个条件确保请求的主机不是www.domain.com或domain.com,下一行匹配并分组该子域名,并且规则本身使用查询字符串url和子域(使用%1进行反向引用)将所有内容重写为/index.php。
https://stackoverflow.com/questions/13022738
复制相似问题