phocks
phocks

Reputation: 3273

.htaccess 301 redirect from one subdirectory to another and preserve folder/directory structure

I've done a lot of searching on how to do this, but none of the solutions seem to be working with this specific problem of redirecting from one subdirectory to another while preserving the original folder/directory structure.

For example I would like to redirect all incoming deep links from: example.com/post/123 to example.com/archive/post/123

Basically I just want to move my original Wordpress blog from the root directory to a subdirectory, but I have a few popular incoming links and I don't want them to break.

Would appreciate any help or if anyone has had similar experience moving blogs yet retaining their incoming links.

Thanks,

Josh

Upvotes: 0

Views: 847

Answers (2)

phocks
phocks

Reputation: 3273

I figured this out a while ago properly and wrote an article about it on Medium:

Basically this is the code I needed in .htaccess in my root directory:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(p/.*)$ http://phocks.org/historic/$1 [R=301,L]
RewriteRule ^(contact.*)$ http://phocks.org/historic/$1 [R=301,L]
RewriteRule ^(about.*)$ http://phocks.org/historic/$1 [R=301,L]
RewriteRule ^(wp-content.*)$ http://phocks.org/historic/$1 [R=301,L]

Upvotes: 1

mashood
mashood

Reputation: 41

Please try this:

For each of your links write as follows in the .htaccess file

redirect 301 /OldSubdirectoy/old/old.htm http://www.domainname.com/NewSubdirectory/new/new/new.htm

Write in this structure for each of your popular links to keep SEO.

Upvotes: 2

Related Questions