0

I've moved my WordPress installation from one domain to another, and I want to use an .htaccess file on the original to redirect visitors to the new page on the new website.

The old site is http://www.steve.doig.com.au/wordpress/.

The new site is http://www.superlogical.net

I tried using tried using the following .htaccess file in the /wordpress directory:

RedirectMatch 301 http://www.steve.doig.com.au/wordpress(.*) http://www.superlogical.net/$1

However, all this does is redirect visitors to the URL: http://www.superlogical.net/wordpress/

I guess this is working properly, but I don't have Wordpress installed in a /wordpress folder on the new domain. How do I remove this from the URL redirected to?

1
  • The RedirectMatch directive matches against a root-relative (starting with a slash) URL-path, not the absolute URL, so the above directive would not have done anything - it would not have matched. Even it did match, it wouldn't have redirected to the /wordpress folder - so there must have been something else going on here. Incidentally, 301 redirects are cached by the browser, so it's quite possible you were seeing a cached response. It's often best to first test with 302 (temporary) redirects for this reason.
    – MrWhite
    Dec 15, 2015 at 15:24

3 Answers 3

2

In the /wordpress/.htaccess file, I changed it to the following:

Options +FollowSymlinks
RewriteEngine On
RewriteRule ^(.*)$ http://www.superlogical.net/$1 [R=301,L]

Which resolved it for me.

0
0

As you’re using regexp on the second parameter you want to escape the dots. Change

http://www.steve.doig.com.au/wordpress(.*)

to

http://www\.steve\.doig\.com\.au/wordpress(.*)

The logic itself, how you meant it, should work though. Passing the following URL-part to the new URL.

3
  • Thanks. It successfully redirects from the /wordpress folder of the old website, but I receive a page not found error when I try to load the URL of an individual wordpress post on the old site. The browser still has the old URL in the address bar, indicating it has not tried to redirect the page. Do I need to include an .htaccess file in every content folder?
    – Steve
    Mar 2, 2011 at 4:26
  • .htaccess files will apply to the directory it is in as well as all sub-directories. See httpd.apache.org/docs/2.2/howto/htaccess.html#what
    – Kissaki
    Mar 5, 2011 at 3:33
  • Thanks, I thought so, but this doesn't change the fact it doesn't work for me.
    – Steve
    Mar 7, 2011 at 2:54
0

I've been told by my webhost to try the following:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?steve\.doig\.com\.au/wordpress/$ [NC]
RewriteRule ^(.*)$ http://www.superlogical.net/$1 [R=301,L]

But this only works for the /wordpress folder, and not for any post or category page.

1
  • This shouldn't have worked at all. The /wordpress/ URL-path is not part of the HTTP_HOST variable, so the condition would have failed, preventing the redirect?
    – MrWhite
    Dec 10, 2015 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.