.htaccess - Help with variables in htaccess redirects -
i want this, redirect:
http://anysubdomain(wildcard).mydomain.com/
to
anysubdomain(wildcard).mydomain.com/page2.php
i tried this:
rewritecond %{http_host} ^(.*)\.mydomain.com$ [or] rewriterule ^/?$ "http\:\/\/$1\.mydomain\.com\/page2\.php" [r=301,l]
but not work, rewritecond part works well, because, subdomain redirected.
but reaches: " .mydomain.com/page2.php"
can me? thanks!
there's few things wrong rewrite:
- the [or] making apply everything
- you don't need escape many chars on rule.
- need pass through hostname variable using %1
- it'll create infinite loop, it'll try redirecting page2.php itself.
this should it:
rewritecond %{request_filename} !.*page2.php$ rewritecond %{http_host} ^(.*)\.mydomain.com$ rewriterule ^(.*)$ http://%1.mydomain.com/page2.php [r=301,l]
Comments
Post a Comment