dir3.domain.com/dir2.html to domain.com/dir/dir2/dir3/index

Using a single web hosting account to host multiple sites

dir3.domain.com/dir2.html to domain.com/dir/dir2/dir3/index

Postby med baha » Fri Aug 17, 2007 5:58 am

Hi every body i'm new to url rewriting
My task is to acheive the following:
dir3.domain.com/dir2.html to domain.com/direrctory/dir2/dir3/index.php
dir2 and dir3 are variable
I tried many code but i failed,Please if some one can help me
Thanks
med baha
 
Posts: 1
Joined: Fri Aug 17, 2007 5:47 am

Postby richardk » Fri Aug 17, 2007 2:32 pm

The sub domains need DNS (to get the request to the server) and the server needs to send sub domain requests to either your document root or /directory.

In your .htaccess file
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com$ [NC]
RewriteRule ^([^/]+)\.html$ /directory/$1/%1/index.php [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 3 guests

cron