【发布时间】:2012-07-09 08:10:37
【问题描述】:
我已成功安装通配符。我设法让动态子域使用一个简单的技巧。
.htaccess:
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
【问题讨论】:
-
所以你想让
pre102.example.com/folder/anotherfolder/script.php?param=1重定向到example.com/folder/anotherfolder/script.php?param=1&pre=102(意思是它改变了浏览器的地址栏)? -
不,浏览器的栏不应该改变。
-
pre102.example.com和example.com是否来自同一个文档根目录?
标签: apache .htaccess subdomain wildcard-subdomain