2

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)

1 Answer 1

2

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).

6
  • What about redirect, rather than rewrite?
    – Steve
    Commented Sep 2, 2012 at 3:21
  • See my edit to the original question please Leif.
    – Steve
    Commented Sep 2, 2012 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
    Commented Sep 3, 2012 at 8:19
  • Good on you! You've nailed it. Thanks for your help.
    – Steve
    Commented Sep 4, 2012 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
    Commented Sep 5, 2012 at 14:28

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.