Forum Moderators: phranque

Message Too Old, No Replies

How to redirect example.com to mydomain.com/blog ?

         

iCyborg

2:17 pm on Apr 26, 2009 (gmt 0)

10+ Year Member



I want to move my blog which is located at example.com to mydomain.com/blog location , what is the .htaccess code I need to put on example.com to google finds that the blog has been moved.

g1smd

3:21 pm on Apr 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There are a couple of thousand prior examples of various types of redirects posted in this forum.

Does your code need to work for both non-www and www? Does it need to retain the same part-parts in the old and new URL? Do any of the URLs have parameters? How do they need to be treated?

Let's see you best effort code and we'll take it from there...

jdMorgan

4:55 pm on Apr 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



... And more fundamentally, is a redirect actually needed?

It is possible, for example, to use a URL of example.com/abc, but have the server get the contents from /blog/abc

It is also possible to use a URL of blog.example.com/xyz and have the server supply content stored in /blog/xyz

Everything depends on what URLs you want to use, and on how/where your install WP.

Jim

iCyborg

5:15 pm on Apr 26, 2009 (gmt 0)

10+ Year Member



I have moved the copy of the blog from example.com to mydomain.com/blog so now the same content can be accessed from 2 locations. I was looking to redirect just www.example.com to [mydomain.com...] through .htaccess as the rest should automatically work, like the url's

g1smd

5:29 pm on Apr 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The example quoted example.com and mydomain.com/blog so I assume a change of domain name is wanted too. However, the OP needs to fully clarify the question. :)

<edit>Ah, a response while I was reading other posts. But now www.example.com is quoted instead of example.com - note the devil really is in the details.</edit>

iCyborg

5:18 am on Apr 27, 2009 (gmt 0)

10+ Year Member



well yes this is change of domains and yes it is www. for one site to non www for other.

My blog is located in www.example.com, I want to move it to [mydomain.com...] I have already moved the wordpress files and copy of database so the blog can be acccess from both urls, now I just need to do 301 redirect :) I hope this clears the air

g1smd

9:10 pm on Apr 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Simple stuff, directly from the forum examples:

# Canonicalise mydomain.com
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com [OR]
RewriteCond %{HTTP_HOST} ^mydomain\.com(\.¦:[0-9]+¦\.:[0-9]+)$
RewriteRule (.*) http://mydomain.com/$1 [R=301,L]
#
# Redirect www and example.com to mydomain.com/blog
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com
RewriteRule (.*) http://mydomain.com/blog/$1 [R=301,L]