How to 301 redirect within same domain?
The most common thing is to 301 redirect a website when moving the whole site from old-location to new-location, but sometimes you need to redirect within your existing website when url paths are changed or pages are removed. This is how to 301 redirect within same domain.
301 redirect within same domain
Open your htaccess file in any text editor. If you don’t have a htaccess file, simply create one. Add one or more 301 redirects and save it as .htaccess then upload it to your server inside the root folder. Use this code to redirect within the same domain:
301 redirect an old path to a new path
RewriteRule ^some-old-path/(.*)$ /some-new-path/$1 [R=301,NC,L]
Or try this code:
RedirectMatch 301 ^/some-old-path/(.+)$ http://www.new-website.com/some-new-path/$1
301 redirect any old path to a new url
Redirect 301 /old-path http://www.new-website.com/
301 redirect any old directory and its contents to a new directory
RewriteRule ^old-folder/(.*)$ /new-folder/$1 [R=301,NC,L]