Anfuca
Anfuca

Reputation: 1329

Redirect all URLs except one

I have this URL:
www.domain.com/old/

I want to redirect all the URLs like www.domain.com/old/xxxx to:
www.domain.com/new/xxxx

Right now, this is working OK. I have this in my .htacces:
RewriteRule ^old/(.*)$ new/$1 [NC,R=301,L]

It's redirecting everything, but I want to keep the www.domain.com/old/
I mean, I want the root (www.domain.com/old/) to keep being www.domain.com/old/

Right now, what is happening is that www.domain.com/old goes to www.domain.com/new

Upvotes: 1

Views: 100

Answers (1)

anubhava
anubhava

Reputation: 785156

Change .* (0 or more characters) to .+ (1 or more characters):

RewriteRule ^old/(.+)$ new/$1 [NC,NE,R=301,L]

Make sure to test it in a new browser or clear browser cache completely.

Upvotes: 1

Related Questions