I have basic domain, for example, domain1.com. Also I have domain2.com which is addon domain, and I want to redirect domain2.com to domain.com?parameter=value, which is basically domain1.com, but with another template, but that path in URL stays same, domain2.com, not domain1.com. .htaccess file is created inside addon domain directory (public_html/domain2.com), and I have these two lines:

RewriteCond % ^domain2.com
RewriteRule ^(.*) http://domain1.com?parameter=value [P]

Rewrite works, but URL in browser changes to domain1.com.

EDIT: U have this code to .htaccess, but URL change to domain1.com, instead to stay on domain2.com.

RewriteCond %{HTTP_HOST} ^domain2\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain2\.com$
RewriteRule ^/?$ "http\:\/\/domain1\.com\/\?parameter\=value" [R=301,L]
  • Is mod_proxy enabled and configured? Presumably your RewriteCond line is not as you have posted as otherwise it wouldn't redirect anything?
    – MrWhite
    Commented Apr 7, 2015 at 21:17
  • Why are you using P proxy?? This is an extremely dangerous thing to do even for highly experienced IT professionals. If your system is not configured exactly right, you will be in trouble fast- possible open proxy and/or vulnerable to other attacks. What problem are you trying to solve?? I rather suspect you are going about it the wrong way. BTW- the notion of a so-called add-on domain is extremely misleading. It may be you are following very bad advice.
    – closetnoc
    Commented Apr 7, 2015 at 22:21
  • @closetnoc, see edit
    – Alan Kis
    Commented Apr 8, 2015 at 20:04
  • I updated the answer. I was not sure all of what you meant in your comment, so I thought updating the answer with more detail could be the first step to a clearer understanding.
    – closetnoc
    Commented Apr 9, 2015 at 16:23

2 Answers 2


Unless I'm mistaken, this should be along the lines what you're looking for:

RewriteEngine On
Options +FollowSyminks
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://my-new-domain.com/$1 [NC,L]

If you're wanting to keep the URL the same, there's no need for a R=302 flag, as it pushes the browser to redirect with a 302 code. Essentially what you're wanting to do is just mask the URL to the proper location.

(Credit to @closetnoc for providing what kicked my train of thought)


Try this:

RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://my-new-domain.com/$1 [R=301,L]

Your RewriteRule from your question is fundamentally incorrect:

RewriteRule ^/?$ "http\:\/\/domain1\.com\/\?parameter\=value" [R=301,L]

My example is a typical blanket redirect that will take the request and parameters from the old domain and forward to the new domain.

In your case the http\:\/\/domain1\.com\/\?parameter\=value does not need to be escaped (using back-slashes) or quoted. The ^(.*)$ http://my-new-domain.com/$1 in my example will take the value from (.*) which would be the URI consisting of the directory path, file, and any parameters and place it at the end of a new request with your new domain using $1.

So any request for www.old-domain.com/eagle-brand/products.php?type=food will become www.new-domain.com/eagle-brand/products.php?type=food.

  • 1
    That's something like my edit up here, rewrite works fine, but URL changes from incoming domain to RewriteRule, now I am not even sure if this can work. I have even try with server alias (parked domain) in http.conf. Incoming URL must stay same, which is impossible I think with RewriteRule.
    – Alan Kis
    Commented Apr 9, 2015 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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