虚拟子域htaccess


virtual subdomain htaccess

我的朋友们,我正在使用正确的虚拟域子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

根本不太清楚你想做什么。你的htaccess文件不像你的例子所示的那样。

尝试:

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