http://www.domain.com/?l=nl --> http://nl.domain.com/

Using a single web hosting account to host multiple sites

http://www.domain.com/?l=nl --> http://nl.domain.com/

Postby tomislav_ » Sun Dec 30, 2007 6:16 am

How can I make

http://www.domain.com/?l=nl&category=12

to

http://nl.domain.com/&category=12

with mod_rewrite?

Thanks for any help I can get.

//t.
tomislav_
 
Posts: 3
Joined: Sun Dec 30, 2007 6:08 am

Postby richardk » Mon Dec 31, 2007 11:27 am

You will need DNS for the sub domains. The server will need to be configured to send the sub domain requests to the directory with the .htaccess file in it (your document root).
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z]{2})\.example\.com$ [NC]
RewriteRule ^(.+)$ /$1?l=%2 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby tomislav_ » Sun Jan 06, 2008 7:14 am

Hi,

Thanks for the input however I must be doing something wrong. I configured the server and set up a http://en.domain.com DNS which i pointing to the same catalogue as http://www.domain.com and added the code blow in the .htaccess file but get some errors, hmmm what am I doing wrong?

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.....


Is there a easy way/tool to debug this?

Options +FollowSymLinks -MultiViews

RewriteEngine On

#specifies where the application server should start from
RewriteBase /

# http://en.domain.com <-- http://www.domain.com/?l=en
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z]{2})\.domain\.com$ [NC]
RewriteRule ^(.+)$ /$1?l=%2 [QSA,L]

# change http://domain.com to http://www.domain.com
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=permanent,L]
tomislav_
 
Posts: 3
Joined: Sun Dec 30, 2007 6:08 am

Postby richardk » Sun Jan 06, 2008 1:10 pm

Try
Code: Select all
Options +FollowSymLinks -MultiViews

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(domain\.com)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=p301,L]

# en.domain.com/* --> /*?l=en
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z]{2})\.domain\.com$ [NC]
RewriteRule ^(.*)$ /$1?l=%2 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby tomislav_ » Mon Jan 07, 2008 10:33 am

I appreciate your help, it seems to work. Thank you very much!!!!!

//t.
tomislav_
 
Posts: 3
Joined: Sun Dec 30, 2007 6:08 am

Same problem but it doesnot work in my case

Postby salman » Fri Mar 07, 2008 2:54 am

Can u please help me in same area as i am having same problem as described and i have tried the solution here provided but i cant able work it out.
Any help will be appreciated.
Thanks
Salman
salman
 
Posts: 2
Joined: Fri Mar 07, 2008 2:51 am

Postby richardk » Fri Mar 07, 2008 4:30 pm

Which problem? A 500 error? Are you allowed to use mod_rewrite? Try this mod_rewrite test. Have you set the sub domains (DNS)? Are the sub domains configured to go to the directory that contains the .htaccess file and mod_rewrite?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

thanks

Postby salman » Sun Mar 09, 2008 10:07 pm

Thanks for Quick reply
I will try this
Thanks
salman
 
Posts: 2
Joined: Fri Mar 07, 2008 2:51 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 19 guests

cron