朋友们,我用的是正确的虚拟域子htaccess文件请帮忙(我已经阅读了htaccess文件的内容,但是我太糊涂了)
输入 => http://www.example.com/
加载 => http://www.example.com/index.php
输入 => http://sample.example.com/
加载 => http://www.example.com/directory/sample/index.php
访问:
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]