1

redirect http://anySubdomain(wildcard).mydomain.com/

to:

anysubdomain(wildcard).mydomain.com/page2.php

i tried with this:

  RewriteCond %{HTTP_HOST} ^(.*)\.mydomain.com$ [OR]
  RewriteRule ^/?$ "http\:\/\/$1\.mydomain\.com\/page2\.php" [R=301,L]

But it does not work, the rewriteCond part works well, because, ANY subdomain is redirected.

But it reaches: " .mydomain.com/page2.php", what makes me think the problem is in the second line

Can you help me? thanks!

John
  • 21
  • 1
  • 2

1 Answers1

0

It should be:

RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com$
RewriteRule ^(.*)$ /page2.php [R=301,L]

The RewriteRule only takes the URL-path (the part after the domain name) for the regex input. Sounds like you want every page to redirect to page2.php, which is what this does.

Chris S
  • 77,945
  • 11
  • 124
  • 216