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

i want to do this: 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!

share|improve this question

1 Answer 1

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.

share|improve this answer

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.