Saeid
Saeid

Reputation: 73

virtual subdomain htaccess

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

Upvotes: 0

Views: 2328

Answers (1)

Jon Lin
Jon Lin

Reputation: 143886

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] 

Upvotes: 1

Related Questions