Redirect Old Directory to New Directory Name

(Mike M) #1


I’m using Wordpress. I want to redirect all URLs from old directory name to new directory name.

I’m trying to do this using .htaccess file with 301 Redirect.

I found this syntax: RewriteRule ^subdirectory/(.*)$ /anotherdirectory/$1 [R=301,NC,L]

For Example 1: RewriteRule ^shopping/(.*)$ /online-shopping/$1 [R=301,NC,L] - (Not Working)

For Example 2 : RewriteRule ^shopping/(.*)$ online-shopping/$1 [R=301,NC,L] - (Working)

As per “Example 1” While I use “/” before another directory that not redirect properly.
And as per “Example 2” without “/” its proper redirect.

Is used as example 2 redirect without “/” is a correct method or not?

Is there any other method available for directory redirect?

Thanks in advance for your help and advice.

(Max) #2

This is the syntax I use that works:

RewriteRule ^shopping/(.*) /online-shoping/$1 [R=301,L]