Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
333 views
in Technique[技术] by (71.8m points)

Redirect 301 of folder except homepage

i have a folder i want to redirect to another folder

i could do this simply with :

Redirectpermanent /old-folder/ https://www.example.com/new-folder/

BUT i need to keep the homepage of this folder as it is

so /old-folder/ should stay as it is, only the internal pages of this folder should be redirected

i tried codes like this :

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
#if not root
RewriteCond %{REQUEST_URI} !^/old-folder/?$ [NC]
#redirect
RewriteRule ^old-folder/(.*)$ http://www.example.com/new-folder/$1 [R=301,L]

but i am getting 404 with this

Any idea ?

Thank you

question from:https://stackoverflow.com/questions/65919235/redirect-301-of-folder-except-homepage

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...