如何.htaccess将子文件夹重定向到另一个子文件夹而不更改浏览器栏中的URL

时间:2014-12-13 19:49:24

标签: .htaccess mod-rewrite redirect url-rewriting subdomain

我再次陷入htaccess! (不是我最强的技能); - )

如何重定向:

www.domain.com/folder1

为:

www.domain.com/folder2/something /

不更改浏览器栏中的网址? (所以继续显示www.domain.com/folder1)

1 个答案:

答案 0 :(得分:1)

尝试将此添加到文档根目录中的htaccess文件:

RewriteEngine On

# externally redirect requests made for folder2/something
RewriteCond %{THE_REQUEST} \ /+folder2/something/
RewriteRule ^ /folder1 [L,R=301]

# internally rewrite the request back to /folder2/something/
RewriteRule ^folder1 /folder2/something/ [L]