Mathias Asberg
Mathias Asberg

Reputation: 3840

.htaccess Redirect Subfolder list Recursive towards new Domain

Relocated website to new domain. The old domain will be used for other purposes so what i need to do is to redirect ~800 Subfolders (users profiles) recursive towards the new url.

I could use something like this

RedirectMatch 301 ^/user/(.*)$ http://new-domain.com/user/$1

This will redirect all sub pages / folders to this user but not if someone visit old-domain.com/user.

How can i redirect both all the specific ~800 subfolder + recursive within the same line ( for every profile )

Upvotes: 1

Views: 1044

Answers (2)

Jon Lin
Jon Lin

Reputation: 143906

Wouldn't it be simpler to just do:

Redirect 301 /user http://new-domain.com/user

Upvotes: 0

anubhava
anubhava

Reputation: 785256

You can tweak your regex like this:

RedirectMatch 301 ^/user(/.*)?$ http://new-domain.com/user$1

This will also redirect old-domain.com/user to new-domain.com/user

Upvotes: 3

Related Questions