2

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?

8
  • How does it fail? Does it not redirect at all or does it redirect to the wrong thing? Apr 7, 2015 at 19:47
  • sorry it doesn't redirect at all.
    – alex
    Apr 7, 2015 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? Apr 7, 2015 at 20:45
  • Have you checked AllowOverride in your configuration??
    – closetnoc
    Apr 7, 2015 at 22:13
  • and are these rules in a .htaccess file or embedded into httpd.conf? Apr 8, 2015 at 4:52

1 Answer 1

1

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]

or

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">
7
  • 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, 2015 at 8:10
  • Here, try this update @alex .
    – Chun
    Apr 8, 2015 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, 2015 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, 2015 at 9:58
  • Still a infinity loop :(
    – alex
    Apr 9, 2015 at 18:30

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.