3

我想通过 htaccess 创建虚拟子域来访问 www.domain.com/test 作为 test.doamin.com 和更多类似 test2.domain.com,test3..。我已经尝试并关注一些链接,但没有发现任何变化。我认为这是因为我共享了从 cpanel 创建的托管和子域。请提供完整的指导。

我关注了以下链接:

  1. https://forums.digitalpoint.com/threads/how-to-create-virtual-dymanic-subdomain-in-php-with-htaccess.1521742/

  2. 虚拟子域 htaccess

  3. 如何使用 htaccess 创建虚拟子域?

  4. http://www.webmasterworld.com/apache/3638570.htm

但是我的问题仍然没有解决。它总是给 Ooops 找不到..

4

1 回答 1

1

I had the same issue before, you must use cpanel to create the subdomain. If I remember right there was a dns issue with this code:

RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteCond %{HTTP_HOST} ([^\.]+)\.domain\.com [NC]
RewriteCond %{REQUEST_URI} !^/index [NC]
RewriteRule ^(.*) http://domain.com/%1 [P]

If you don't want to use cpanel creating wildcard domain entry such as *.domain.com should help.

于 2014-09-19T06:16:34.040 回答