1

我正在尝试使用 mod_rewrite 配置我所看到的“伪子域”(a la Craigslist),以便当用户导航到“location.mydomain.com”时,它会将 url 重写为“index.php?loc” =x'。

以下代码按描述工作,我的问题是:如何重写这些指令以处理除位置之外的其他参数。例如“location.mydomain.com?user=me”

无论如何,这是我的代码:

RewriteEngine On 
RewriteCond %{HTTP_HOST} !^$ 
RewriteCond %{HTTP_HOST} !^(www\.)?mydomain\.com$ [NC] 
RewriteCond %{HTTP_HOST}<->%{REQUEST_URI} ^(www\.)?([^.]+).*<->/([^/]+) [NC] 
RewriteCond %2<->%3 !^(.*)<->\1$ [NC] 
RewriteRule ^(.+) index.php\?loc=%2 [L]

感谢您的回复。

4

0 回答 0