I run WordPress in Network mode, which means I can have multiple websites running off one installation of WordPress. Each website runs as a subdomain. WordPress handles this using .htaccess, and a wildcard subdomain pointing to the location of WordPress, so there are no actual subdomains created in cPanel; just a wildcard subdomain in cPanel, ad WordPress handles the rest.

I want to 301 redirect http://one.example.com/portfolio to http://two.example.com/portfolio.

If I only have 1 .htaccess file in the web root of example.com, how do I achieve this?

EDIT: I have used the following but it does not work:

RewriteCond %{HTTP_HOST} ^steve\.doig\.com\.au$ [NC]
RewriteRule ^/products.html http://tech.doig.com.au/products.html/ [L,R=301]

(this is to redirect http://steve.doig.com.au/products.html to http://tech.doig.com.au/products.html)


If I am not mistaken, you should be able to do something like this:

RewriteCond %{HTTP_HOST} ^one\.example\.com$ [NC]
RewriteRule ^portfolio$ http://two.example.com/portfolio [L,R=301]

This is from memory, but maybe you get the idea (HTTP_HOST).

  • What about redirect, rather than rewrite?
    – Steve
    Sep 2 '12 at 3:21
  • See my edit to the original question please Leif.
    – Steve
    Sep 2 '12 at 3:57
  • Okay, I had the time to try it myself. There is slash too much in RewriteRule. Try: RewriteRule ^portfolio$ two.example.com/portfolio [L,R=301] (I updated my answer accordingly)
    – Leif
    Sep 3 '12 at 8:19
  • Good on you! You've nailed it. Thanks for your help.
    – Steve
    Sep 4 '12 at 9:10
  • 2
    You cannot, but there seem to be some workarounds, like this one: my.galagzee.com/2009/02/11/… Also try searching for "one rewritecond multiple rewriterule".
    – Leif
    Sep 5 '12 at 14:28

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.