rogerb
rogerb

Reputation: 251

301 redirect from one directory to another

I am using the sitewide redirect solution provided by @Panama Jack Redirect entire website to https - non-www to www except subdomains

In addition, I also need a 301 re-direct from one directory to another i.e.

Redirect FROM

 1. www.example.com/directory1/?q1=1234&page=1
 2. http://www.example.com/directory1/?q1=1234&page=1
 3. example.com/directory1/?q1=1234&page=1
 4. http://example.com/directory1/?q1=1234&page=1
 5. https://example.com/directory1/?q1=1234&page=1

To

 https://www.example.com/directory2/?q1=1234&page=1

Thanks in advance

Upvotes: 1

Views: 119

Answers (1)

anubhava
anubhava

Reputation: 786349

You can add this new rule below your earlier 301 http->https rule:

RewriteRule ^directory1(/.*)?$ /directory2$1 [NC,L,NE,R=301]

QUERY_STRING will be automatically carried over to target URL.

Upvotes: 1

Related Questions