【问题标题】:Redirection within domain using masking使用屏蔽在域内重定向
【发布时间】:2012-10-01 19:13:31
【问题描述】:

我希望访问者使用屏蔽从一个子域重定向到另一个子域。

我的网络根目录 example.com 中有一个文件夹 demo。当用户登录时,将通过输入他的输入名称创建子域,例如 mystore,他将获得 mystore.example.com。我希望他重定向到演示文件夹(子域),但他不应该知道这一点。即使在重定向之后,他也应该得到 mystore.example.com

是否可以使用域屏蔽?我该怎么做?我应该在哪里写代码?

【问题讨论】:

  • 你能说明什么是“使用屏蔽重定向”吗?你能发布你的重定向代码吗?

标签: php redirect subdomain


【解决方案1】:

实际上这是子域通配符,您的主机必须启用它,您可以使用.htaccess动态创建子域:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC]
RewriteRule ^$ http://www.example.com/demo/?store_name=%2 [L]

这意味着mystore.example.com实际上会转到http://www.example.com/demo/?store_name=mystore

【讨论】:

  • 谢谢,但它会从 html 表单中获取商店名称吗?我应该如何提及它
  • 什么形式?如果您有表格,只需将他重定向到$_POST['storename'] 或您输入的名称。
猜你喜欢
  • 2018-04-19
  • 2010-09-14
  • 2012-04-14
  • 1970-01-01
  • 2012-07-29
  • 1970-01-01
  • 2021-04-08
  • 2017-02-08
  • 1970-01-01
相关资源
最近更新 更多