I have this which i can't get to work

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domainalias.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domainalias\.com$
RewriteRule ^(.*)$ http://www.maindomain.com/specific-url/ [R=301,L]

it doesn't redirect to /specific-url/ any ideas?

  • How does it fail? Does it not redirect at all or does it redirect to the wrong thing? – Stephen Ostermiller Apr 7 '15 at 19:47
  • sorry it doesn't redirect at all. – alex Apr 7 '15 at 20:42
  • Those rewrite rules should cause redirects if they are put in the right place. What file are you putting them in? Are the alias domain and the main domain served out of the same folder currently? – Stephen Ostermiller Apr 7 '15 at 20:45
  • Have you checked AllowOverride in your configuration?? – closetnoc Apr 7 '15 at 22:13
  • and are these rules in a .htaccess file or embedded into httpd.conf? – Mike Apr 8 '15 at 4:52

If you're looking to redirect a user from an old domain to a new domain on a specific page,
you can use this:

======= update ========

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domainalias\.com [NC]
RewriteRule ^(.*)$ http://maindomain.com/specific-url/$1 [R,L]


RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domainalias.com$ [NC]
RewriteRule ^(.*)$ http://www.maindomain.com/specific-url/ [R=301,L]

========= ### =========

You can also redirect using a meta tag:

<meta http-equiv="refresh" content="0; url=http://www.example.org/newpage.html">
| improve this answer | |
  • no in my case they have registered a specific domainname just for a specific page. So i have created a domainalias but need to redirect to the specific page – alex Apr 8 '15 at 8:10
  • Here, try this update @alex . – Chun Apr 8 '15 at 8:22
  • almost but i get a infinty loop which reads something like maindomain.com/specific-url/specific-url/specific-url/… – alex Apr 8 '15 at 8:36
  • What happens if you change the 3rd line for this instead RewriteRule ^(.*)$ http://www.maindomain.com/specific-url/ [L,R=301] – Chun Apr 8 '15 at 9:58
  • Still a infinity loop :( – alex Apr 9 '15 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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