htacces,将一些子文件夹重定向到另一个子文件夹

时间:2015-05-10 20:55:03

标签: html .htaccess

我需要将子文件夹重定向到另一个子文件夹。

我的问题是我想重定向所有链接,如

http://example.org/make/satellite/*  or http://example.org/space/satellite/* 

  http://example.org/satellite/*

但它确实无效。我正在使用此代码

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.org [NC]
RewriteRule ^(.*)$ example.org$1 [L,R=301]
RedirectMatch 301 ^/satellite/(.*)$ http://example.org/satellite/$1

如何使用htacces文件执行此操作?

由于

2 个答案:

答案 0 :(得分:1)

你必须寻找两个匹配并忽略第一个:

RedirectMatch 301 ^/(.*)/satellite/(.*)$  http://example.org/satellite/$2

答案 1 :(得分:0)

在Root / .htaccess文件中尝试此操作:

RedirectMatch 301 ^/make/satellite/(.*)$  http://example.org/satellite/$1 
RedirectMatch 301 ^/space/satellite/(.*)$  http://example.org/satellite/$1 

这会将http://example.com/make/satellite/http://example.com/space/satellite/重定向到http://example.com/satellite