.htaccess redirect help

Babbles

Diamond Member
Jan 4, 2001
8,253
14
81
I hope there is a simple solution, but I am having trouble finding an answer.

I moved my Wordpress install from subdomain to the top-level domain and I would like to do a .htaccess redirect to point the old page locations to their respective new location.

So I want to redirect: blog.website.com/Page01
to: www.website.com/Page01

Currently I have:

Code:
Options -Indexes +FollowSymLinks

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^WEBSITE.COM/ [NC]
RewriteRule ^(.*)$ http://www.WEBSITE.COM$1 [L,R=301]

RedirectMatch 301 http//blog.WEBSITE.COM/(.*)$ http://www.WEBSITE.COM/$1

This seems to display the content from the new location, but the URL in the browser doesn't update (i.e. keeps blog.website instead of www.website).

Any help?
 

MrColin

Platinum Member
May 21, 2003
2,403
3
81
I was looking for a solution to a similar issue and found this on wikipedia
Using .htaccess for redirection

When using the Apache web server, directory-specific .htaccess files (as well as apache's main configuration files) can be used. For example, to redirect a single page:

Redirect /oldpage.html http://www.example.com/newpage.html [R=301,L]

The above format used to work until somewhere around version 2.2.14. In the Apache HTTP server version 2.2.14 it has been found[by whom?] (on three separate servers, not a big sample but better than one) that placing a line of the above format in an .htaccess file causes an Internal Server Error for the entire site. Instead you should use the format dictated by the Apache Foundation [6] such as:

Redirect permanent /oldpage.html http://www.example.com/newpage.html
Redirect 301 /oldpage.html http://www.example.com/newpage.html
 

Aluvus

Platinum Member
Apr 27, 2006
2,913
1
0
Just use the same format as you are already using for your first redirect.

Code:
RewriteCond %{HTTP_HOST} ^blog.example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

What you are wanting to do (changing the URL that is displayed) is known as an external redirect (as opposed to internal redirect).