.htaccess redirect all files in one folder to exac

2019-05-19 23:57发布

问题:

We simply have to move every page inside of a directory called "Music" to a directory called "Information"... That's the only change. There's lots of links to pages music and we don't want to break them all. I'm not great at rewrite conditions....

Basically, all I want to do is when a user types in music/index.php, for example, or music/life/mypage.php, to simply redirect it to information/index.php or information/life/mypage.php... just change from music to information. And I do want the correct URL (information) to show in the URL box.

...I'm pretty exasperated. I've been trying to get this thing all darn afternoon!

回答1:

Use backreferences for this one:

RewriteRule ^foo/(.*)$ bar/$1


回答2:

RedirectMatch ^/foo/bar/(.*) http://www.wherever.org/a/foo/bar/$1