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

Categories

I'm trying to redirect a folder and all its sub files to a URL with a .htaccess file.

But

Redirect 301 /abc/cba/ http://www.aaa.com/

Will make /abc/cba/ddd/index.html redirect to http://www.aaa.com/ddd/index.html

What I want is redirect /abc/cba/ /abc/cba/ddd/index.html to http://www.aaa.com/

Could anyone help? Thanks. If anything not clear, please let me know.

See Question&Answers more detail:os

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

1 Answer

By default, Redirect sort of maps the path node to a new path node, so anything after the first path gets appended to the target URL.

Try:

RedirectMatch 301 ^/abc/cba/ http://www.aaa.com/?

Or if you'd rather use mod_rewrite instead of mod_alias:

RewriteEngine On
RewriteRule ^/?abc/cba/ http://www.aaa.com/? [R=301,L]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...