【发布时间】:2017-03-30 12:27:25
【问题描述】:
我可以重写这个请求类型:
http://name1.domain1.com/ -> index.php?subdomain=name1
http://name2.domain2.org/ -> index.php?subdomain=name2
我需要在 php 脚本 ( index.php ) 中管理子域 GET 变量。 我需要所有域的通用规则。
这是我的 .htaccess 文件,但它不起作用。
RewriteEngine On
# Parse the subdomain as a variable we can access in PHP, and
# run the main index.php script
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} !^www
RewriteCond %{HTTP_HOST} ^([^\.]+)\.([^\.]+)\.([^\.]+)$
RewriteRule ^(.*)$ /$1?subdomain=%1
谢谢。
【问题讨论】: