简体   繁体   中英

Redirect all files from wordpress on subdirectory to new domain

I am moving my site to a different e-commerce platform which won't allow WordPress on it so I am keeping my blog on the old server but will need to assign a new domain to it since the old one was moved to the new e-store.

I need a 301 with htaccess www.olddomain.com/blog to www.newdomain.com .

I already tried this without success:

RewriteCond %{HTTP_HOST} ^(www\.)?oldomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]

Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com  [NC]
RewriteRule ^blog/(.*)  http://www.newdomain.com/$1 [R=301,NC,L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Any suggestions?

Use the below code for redirecting olddomain.com/blog to newdomain.com

    Options +FollowSymlinks
    RewriteEngine on
    rewriterule ^blog(.*)$ http://new.com/$1 [r=301,nc]

Or you can even generate custom redirects and htaccess rules at http://www.webconfs.com/htaccess-redirect-generator.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM