Reputation: 1
My site needs to redirect everything with four subfolders to a different subdomain...
domain.com/1/2/3/4
must not redirect
and
domain.com/1/2/3
must redirect to
newsub.domain.com/1/2/3
Upvotes: 0
Views: 465
Reputation: 2057
If you want to redirect domain.com/1/2/3/4
but not domain.com/1/2/3
use this:
RewriteEngine on
RewriteBase /
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ http://sub.domain.com/$1/$2/$3/$4 [L]
If you want to redirect domain.com/1/2/3
but not domain.com/1/2/3/4
this should help you:
RewriteEngine on
RewriteBase /
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ http://sub.domain.com/$1/$2/$3 [L]
Upvotes: 1