2012-08-23 179 views
0

我的朋友,我使用的是正確的虛擬域副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

+1

你只需要指向每個子域和不同webroots。它現在在工作嗎?你準確的問題是什麼? – Tchoupi

+0

現在我使用這段代碼,我完成了以下步驟。 1)* .example.com RewriteEngine on RewriteCond%{HTTP_HOST}!^ www.lidlike.com RewriteCond%{HTTP_HOST} ^([^。] +)。lidlike.com RewriteRule^$ /index.php? name =%1 [L] – Saeid

+0

沒有人?她謝謝我,我可以幫助 – Saeid

回答

1

根本不清楚你想要做什麼。您的htaccess文件不會像您的示例所示那樣執行任何操作。

嘗試:

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

不幸的是我仍然無法做到 – Saeid

+0

我有兩個要求,第一個是 回車=> http://www.example.com/ Load => http:// www。 example.com/ Enter => http://sample.example.com/ Load => http://www.example.com/directory/sample/ 第二種情況:使用PHP的獲取子域名 index.php \t <?php \t $ SubName = $ _ GET ['name']; \t?> – Saeid