[英]I am trying to use htaccess to redirect subdomain to domain query
I am trying to redirect myname.mydomain.com to www.mydomain.com/search/?q=myname 我正在尝试将myname.mydomain.com重定向到www.mydomain.com/search/?q=myname
I have tried: 我努力了:
ReWriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain.com$
RewriteRule ^(.*)$ http://www.mydomain.com/search/?q=$1 [QSA,L]
The redirect works but sends me to www.mydomain.com/search/?q= it does not include the search string (ie. subdomain) 重定向有效,但将我发送到www.mydomain.com/search/?q=,它不包含搜索字符串(即子域)
What am I doing wrong? 我究竟做错了什么?
Thanks 谢谢
You need to use %1
instead since you are capturing group in RewriteCond
: 您需要使用
%1
来代替,因为您要在RewriteCond
中捕获组:
ReWriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain.com$
RewriteRule ^(.*)$ http://www.mydomain.com/search/?q=%1 [QSA,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.