.htaccess将文件夹重定向到网址

编程入门 行业动态 更新时间:2024-10-21 11:54:23
本文介绍了.htaccess将文件夹重定向到网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

但是

Redirect 301 /abc/cba/ www.aaa/

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

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

有人可以帮忙吗?谢谢。如果不清楚,请通知我。

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

推荐答案

默认情况下,重定向将路径节点映射到新的路径节点,因此第一个路径之后的所有内容都会附加到目标URL。

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.

尝试:

RedirectMatch 301 ^/abc/cba/ www.aaa/?

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

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

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

更多推荐

.htaccess将文件夹重定向到网址

本文发布于:2023-10-31 13:05:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546171.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   重定向   网址   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!