I have some files placed under a particular folder in my old domain like this: http://www.olddomain.com/folder1/.
I want to redirect all requests that try to access files under this folder to a new domain. Example: http://www.olddomain.com/folder1/page1.html -> http://www.newdomain.com/page1.html
How do I accomplish this using .htaccess?
Use a 301 redirect . htaccess to point an entire site to a different URL on a permanent basis. This is the most common type of redirect and is useful in most situations. In this example, we are redirecting to the "example.com" domain.
Right-click a folder that you want to redirect (for example, Documents), and then select Properties. In the Properties dialog box, from the Setting box, select Basic - Redirect everyone's folder to the same location.
Give this a shot.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^folder1(.*)$ http://www.newdomain.com/$1 [L,R=301]
</IfModule>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With