I'm launching a new site on WordPress but would like all of my old links to remain active. To make this possible I've moved my present site into开发者_运维百科 a subdirectory (/oldsite) and installed the new wordpress site directly in root.
How would I go about redirectin any url that matches the old path style into the /oldsite directory so that:
http://example.com/stories/read/4231/some-story-title
is automatically redirected to
http://example.com/oldsite/stories/read/4231/some-story-title
The same would go for many other domain patterns like:
http://example.com/exclusives
becoming http://example.com/oldsite/exclusives
and a few more.
I don't want all requests to go into the /oldsite directory, since I will rely onmy WordPress instance in root.
.htaccess is still somewhat cryptic to me, so I would appreciate any direction.
Something like the following should work.
RewriteCond %{REQUEST_URI} ^/(stories|exclusives)/ [NC]
RewriteRule .* /oldsite/%1 [R=301,L]
Try this one
RewriteCond %{HTTP_HOST} ^(example.com)$ [NC]
RewriteRule ^(.*)$ /oldsite/%2%{REQUEST_URI} [QSA,L]
It will not actually redirect .. It will internally run from oldsite folder
If u want to redirect then add [R=301,L]
to RewriteRule
精彩评论