我正在尝试将文件夹及其所有子文件重定向到带有.htaccess文件的URL .
但
Redirect 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/
有人可以帮忙吗?谢谢 . 如果有任何不清楚的地方,请告诉我 .
3 回答
默认情况下,
Redirect
将路径节点映射到新路径节点,因此第一个路径之后的任何内容都会附加到目标URL .尝试:
或者,如果你更愿意使用mod_rewrite而不是mod_alias:
这是另一个对我有用的mod_rewrite规则的例子
我想将子目录重定向到同一域的根目录 .
更多例子可以在这里找到:http://coolestguidesontheplanet.com/redirecting-a-web-folder-directory-to-another-in-htaccess/
我不得不将旧网站版本的网址重新路由到新版本,所以我这样做是为了重新路由从about-us / *到about-us.html的任何链接
它没有做的是重写域名:domain.com/about-us/thing.html => domain.com/about-us.html .
它适用于没有扩展名的东西domain.com/about-us/something-in-url => domain.com/about-us.html
我添加了下面的行重定向.jpg和.png,但它不适用于.html,我找不到原因 .