简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM