views:

45

answers:

2

Hi,

I want to write a .htaccess from which the following action should be done.

I have domain like

www.xyz.com 

and am putting many articles on that. so it wil become

www.xyz.com/article1-tutorial/
www.xyz.com/article2-tutorial/
www.xyz.com/article3-tutorial/

But instead of that i need like this.

www.article1-tutorial.xyz.com/
www.article2-tutorial.xyz.com/
www.article3-tutorial.xyz.com/

Please help to find the solution. I know we cant go for subdomain concept and only the way is redirection. So whats is the solution?

+1  A: 

Can you use the reverse proxy engine of apache?

Reverse Proxying with Apache

Aurril
+2  A: 

You can use apache's mod rewrite like so:

   RewriteEngine On
   RewriteBase /
   RewriteCond %{HTTP_HOST} !www.domain.com$ [NC]
   RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).domain.com [NC]
   RewriteRule (.*) %2/$1 [L]

when a user goes to http://article1-tutorial.domain.com/ server internaly rewrites therequest to http://www.domain.com/article1-tutorial

clyfe
You forgot, that A record for subdomains at the DNS must be point to the domain.com and have value "*"
antyrat
thanks for your reply. And what you meant by "A record for subdomains at the DNS must be point to the domain.com and have value "*" ", I will try it out.
Ela
@antyrat "A record for subdomains at the DNS must be point to the domain.com and have value "*" What you meant by this line?
Ela
I mean that all subdomains mus be point to the main domain. If so you can easy show article to user according to the HTTP_HOST value.
antyrat