0
votes

my client changed his wordpress website to a new domain. I tried with the htaccess to redirect 301 the articles dynamicaly but it's not working.

The URL format of articles are : /%year%/%monthnum%/%day%/%postname%/

I put this in htaccess but not working :

redirect 301 /([0-9]*)/([0-9]*)/([0-9]*)/(.*)/ http://www.newdomain.com/$1/$2/$3/$4/

Can you help me ? Thanks

EDIT: This is my actual .htaccess :

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteRule ^(\d+)/(\d+)/(\d+)/([\w\-]+)/?$ http://www.newdomain.com/$1/$2/$3/$4/ [R=302,NC,L]
1

1 Answers

0
votes

You can use mod_rewrite for this:

RewriteEngine On
RewriteRule ^(\d+)/(\d+)/(\d+)/([\w\-]+)/?$ http://www.newdomain.com/$1/$2/$3/$4/ [R=302,NC,L]

If you are happy with the redirect, and would like to make it permanent, you can change 302 to 301.