0

My friends, I am using the correct virtual domain sub htaccess file please help (I have read the contents of the htaccess file, but I'm too confused)

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

Enter => http://sample.example.com/
Load => 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] 

I have two requirements, the first

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

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

The second case: get a sub domain name with PHP's

index.php
    <?php
    $SubName=$_GET['name'];
    ?>

I got it but I can not understand

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

casperOne
  • 73,706
  • 19
  • 184
  • 253
Saeid
  • 73
  • 2
  • 10
  • 1
    You just need to point each subdomain and different webroots. Is it now working? What's your question exactly? – Tchoupi Aug 23 '12 at 13:31
  • Now I use this code I've done the following steps. 1) *.example.com RewriteEngine on RewriteCond %{HTTP_HOST} !^www.lidlike.com RewriteCond %{HTTP_HOST} ^([^.]+).lidlike.com RewriteRule ^$ /index.php?name=%1 [L] – Saeid Aug 23 '12 at 13:37
  • No one? She thanks me and I can help – Saeid Aug 23 '12 at 15:44

1 Answers1

1

Not very clear at all what you're trying to do. Your htaccess file doesn't do anything like what your examples indicate.

Try:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.lidlike.com
RewriteCond %{HTTP_HOST} ^([^.]+).lidlike.com
RewriteRule ^$ /directory/%1/index.php [L] 
Jon Lin
  • 142,182
  • 29
  • 220
  • 220
  • Unfortunately I am still not able to do before – Saeid Aug 25 '12 at 17:21
  • I have two requirements, the first Enter => http://www.example.com/ Load => http://www.example.com/ Enter => http://sample.example.com/ Load => http://www.example.com/directory/sample/ The second case: get a sub domain name with PHP's index.php – Saeid Aug 25 '12 at 17:27