Htaccess redirect all content from domain/folder t

2019-08-06 23:23发布

问题:

I have a website here:

Wordpress Site

Now, i need to redirect all requests to that domain/directory to otherdomain, in this case designcenter.com.ve while keeping folder hierarchy as it is, for example:

http://olddomain/wordpress/post - to - http://newdomain/post or maybe http://newdomain/wordpress/post

Already tried some answers here, but no still luck, no redirecting and plus had to delete htaccess and restore permalinks on wordpress.

Somebody could shed some light on this?

Thanks in advance!

回答1:

You just need this rule but make sure this rule is your first rule in your DocumentRoot/.htaccess of olddomain.com:

RewriteRule ^wordpress(/|$) http://www.newdomain.com%{REQUEST_URI} [L,NC,NE,R=301]

In case your .htaccess is in /wordpress/.htaccess then use:

RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,NE,R=301]

as your first rule.



回答2:

I always prefer the popular Redirection plugin. Since you don't need to touch the .htaccess file. And you can manage everything from Wordpress Admin itself

Update:2: You can find all the basic redirect rules here.

Use this in regex... (Based on your usecase)

 Source: /(.*) 
 Target: http://newdomain.com/$1

UPDATE: I noticed... you haven't updated the permalinks in your 2nd site... Do that first and then also see the site URL is properly mentioned in your wordpress admin settings page.



回答3:

Give this a shot.

 <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteRule ^folder1(.*)$ http://www.newdomain.com/$1 [L,R=301]

    </IfModule>