1

我已成功安装通配符。我设法让动态子域使用一个简单的技巧。

.ht 访问:

Options +FollowSymLinks
        RewriteEngine On
        RewriteBase /

        # *.example.com
        RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
        RewriteCond %{HTTP_HOST} ^([a-zA-Z0-9]+)\.example\.com$ [NC]
        RewriteCond %{REQUEST_URI} !^/?subdomain\.php$
        RewriteRule .? subdomain.php?subdomain=%1&path=%{REQUEST_URI} [L,QSA]

目前在something.example.com 中显示了subdomain.php 的输出,很棒。

但我想让它工作,因为我可以输入

pre102.example.com/folder/anotherfolder/script.php?param=1

并显示输出

example.com/folder/anotherfolder/script.php?param=1&pre=102

4

1 回答 1

1
RewriteCond %{QUERY_STRING} !pre=[0-9]
RewriteCond %{HTTP_HOST} ^pre([0-9]+)\.example\.com$ [NC]
RewriteRule ^(.*)$ /$1?pre=%1 [L,QSA]
于 2012-07-10T14:22:34.220 回答