Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I will put it as simple as I can. I really need your help, so one of the domains let's say example1.com is set to point to real_domain.com, basically what happens is when you type into your browser example1.com it will redirect you to real_domain.com.

So basically I need and if that is even possible. I would like to write htaccess file on the real_domain.com so that according to different requested URL points it to certain subdomain, let say if you type in your browser example1.com it should bring you to real_domain.com/es.

My question is if that is even possible to do and if so HOW TO DO IT, I tried something like this but it didn't happen:

RewriteCond %{HTTP_HOST} ^example.com [NC]

RewriteRule ^(.*)$ http://www.real_domain.com/es [L,R=301]

Is that even a right approach? Can this be done, if so, every help is very much appreciated. Sorry if the topic is already somewhere I tried it but didn't found it.

P.S. I don't have access to example.com htaccess file it just redirected to real_domain.com I assume with moniker.com.

Thank you in advance for the help.

share|improve this question
add comment

1 Answer

If I understand correctly, the .htaccess file on real_domain.com should evaluate where the request is coming from, so I'd give it a shot with testing against the "referer" header in the HTTP Request:

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://example\.com [NC]
RewriteRule ^(.*)$ http://www.real_domain.com/es [L,R=301]

I'd consider catching www.example.com, too.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.