【发布时间】:2020-09-03 03:41:58
【问题描述】:
所以我试图让每个用户都有一个我的网站有一个子域
每当用户连接到通配符子域时,它都会将用户带到domain.com/send.php?username='subdomain',但我想隐藏重定向,因为它为用户显示subdomain.domain.com
我在 Apache Virtual Host 上直接修改,这里是我的条件
RewriteEngine 上
RewriteCond %{SERVER_NAME} =domain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
RewriteCond %{HTTP_HOST} !^(www)。 [NC]
RewriteCond %{HTTP_HOST} ^(.).(.).com [NC]
RewriteRule (.) https://www.%2.com/send.php?username=%1 [NC,L]
RewriteCond %{HTTP_HOST} ^(.)$ [NC]
重写规则 ^https://%1%{REQUEST_URI} [L,NE,R=301]
如果我使用 [P] 标志,我会收到 403 错误,如果我使用 L 标志,即使没有 R,它也会显示重定向的 URL。
我正在努力解决问题,谢谢!
【问题讨论】:
标签: .htaccess redirect subdomain virtualhost wildcard-subdomain