【问题标题】:how to redirect domain to dynamic subdomains?如何将域重定向到动态子域?
【发布时间】:2013-02-09 21:18:09
【问题描述】:

我在 mysite.com 有商店,在这个网站上,有一些商店,比如苹果和...。 用户可以使用http://apple.mysite.com等虚拟子域查看此商店

因此,我在根文件管理器中创建了 .htaccess:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mysite.com$
RewriteCond %{HTTP_HOST} ^(.*)\.mysite.com$
RewriteRule ^$ /stores.php?id_store=%1 [P,L]

然后在 Cpanel 的“子域”中创建 *.mysite.com 并在“文档根目录”中设置 /public_html

现在,如何使用 htaccess 代码将域停放或重定向到此动态子域? 例如: 停放或重定向 applestore123.comapple.mysite.com

我有共享主机服务器。

【问题讨论】:

  • 请帮帮我!如何解决这个问题? :s

标签: apache .htaccess mod-rewrite


【解决方案1】:

对于 applestore123.com 到 apple.mywebsite,您必须更改您的 htaccess 规则,例如:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^applestore123.com$ [NC]
RewriteRule (.*) apple.mysite.com$ [QSA,R=301,L]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-19
    • 2021-09-09
    • 2012-04-01
    • 1970-01-01
    • 2015-06-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多