虚拟子域名htaccess

时间:2012-08-23 13:25:51

标签: php .htaccess subdomain virtual

我的朋友们,我正在使用正确的虚拟域子htaccess文件请帮助(我已经阅读了htaccess文件的内容,但我太困惑了)

输入=> http://www.example.com/
加载=> http://www.example.com/index.php

输入=> http://sample.example.com/
加载=> http://www.example.com/directory/sample/index.php

htaccess的:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.lidlike.com
RewriteCond %{HTTP_HOST} ^([^.]+).lidlike.com
RewriteRule ^$ /index.php?name=%1 [L] 

我有两个要求,第一个

Enter => http://www.example.com/
Load => http://www.example.com/

Enter => http://sample.example.com/
Load => http://www.example.com/directory/sample/

第二种情况:使用PHP的

获取子域名
index.php
    <?php
    $SubName=$_GET['name'];
    ?>

我明白了,但我无法理解

Options +FollowSymLinks -Multiviews
RewriteEngine on
RewriteBase /
#
# Canonicalize the hostname
RewriteCond www.%{HTTP_HOST} ^(www)\.(example\.com) [OR]
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.(example\.com) [OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.(example\.com) [OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.(example\.com). [OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.(example\.com):[0-9]+
RewriteRule (.*) http://%1.%2/$1 [R=301,L]
#
# If subdomain is NOT www
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
# Extract (required) subdomain to %1
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com$
# Rewrite if requested URL resolves to existing file or subdirectory in /subdomains/<subdomain>/ path
RewriteCond %{DOCUMENT_ROOT}/subdomains/%1/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/subdomains/%1/$1 -d
RewriteRule (.*) /subdomains/%1/$1 [L]

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

1 个答案:

答案 0 :(得分:1)

根本不清楚你要做什么。您的htaccess文件没有像示例所示的那样执行任何操作。

尝试:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.lidlike.com
RewriteCond %{HTTP_HOST} ^([^.]+).lidlike.com
RewriteRule ^$ /directory/%1/index.php [L] 
相关问题