如果我是用户访问该网站
http://subdomain.example.com/faq/index.html
如何将其作为
传递给服务器http://subdomain.example.com?q=subdomain.com/faq/index.html?
关键是我希望网址看起来仍然像第一个网址,所以我不想重定向它。
我也在使用php,但我认为我不能用它完成这个。
答案 0 :(得分:1)
假设第二个?
实际上只是原始问题中的问号,您可以捕获查询字符串组件,如下所示:
RewriteBase /
RewriteCond %{HTTP_HOST} ^([A-Z0-9-]+)\.example\.com$ [NC]
RewriteRule ^(.*)$ /?q=%1.com/$1 [L]