.htaccess 将文件夹重定向到一个 url [英] .htaccess redirect folder to a url

查看:30
本文介绍了.htaccess 将文件夹重定向到一个 url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将文件夹及其所有子文件重定向到带有 .htaccess 文件的 URL.

但是

重定向 301/abc/cba/http://www.aaa.com/

将使 /abc/cba/ddd/index.html 重定向到 http://www.aaa.com/ddd/index.html

我想要的是将 /abc/cba//abc/cba/ddd/index.html 重定向到 http://www.aaa.com/

有人可以帮忙吗?谢谢.如果有什么不清楚的,请告诉我.

解决方案

默认情况下,Redirect 将路径节点映射到一个新的路径节点,因此之后的任何内容第一个路径被附加到目标 URL.

试试:

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

或者,如果您更愿意使用 mod_rewrite 而不是 mod_alias:

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

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.

解决方案

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]

这篇关于.htaccess 将文件夹重定向到一个 url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆