Reputation: 2024
I like to redirect all pages under olddomain.com/subdirectory/ to be redirected to newdomain.com?
The newdomain.com site has a new URL structure, so I want every page under the olddomain.com/subdirectory/urls to be redirected to the newdomain.com homepage.
I tried below code.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^olddomain.com/subdirectory/$ [NC]
RewriteRule ^(.*)$ http://newdomain.com [R=301,L]
</IfModule>
But its redirecting with existing url like http://newdomain.com//url
and its through 404 error.
Any help highly appreciated. Thanks
Upvotes: 1
Views: 2901
Reputation: 41249
You can use the following rule :
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^subdir/(.*)$ http://newdomain.com/ [R=301,L]
</IfModule>
Upvotes: 4