htaccess 301 redirect folder, but not subfolders

后端 未结 6 2071
余生分开走
余生分开走 2020-12-10 11:13

I need to redirect from:

http://example.com/folder

to http://example.com/newfolder

But leave:

http://example.com/folder/subfolder

Whe

6条回答
  •  醉梦人生
    2020-12-10 11:51

    I just ran into this and here's the solution I came up with. I prefer this method because it doesn't redirect any subdirectory.

    RewriteCond %{REQUEST_URI} ^/root-directory[/]?
    RewriteCond %{REQUEST_URI} !^/root-directory/+[/]?
    RewriteRule (.*) http://www.example.com/ [R=301,L]
    

提交回复
热议问题