使用htaccess将URL重定向到子/子文件夹

时间:2014-01-07 14:42:13

标签: .htaccess

我想将子/子文件夹网址重定向到特定网址。

它适用于正常的重定向,例如:

Redirect /folder https://mydomain.com/therestoftheurl

但我需要很多文件夹/ folder1或文件夹/文件夹2重定向。 它无法解决这个问题:

Redirect /folder/folder1 https://domain.com/target

我在这个解决方案中发现了一个相反的问题。

    RewriteCond %{HTTP_HOST} ^mydomain.in$ [OR]
RewriteCond %{HTTP_HOST} ^www.mydomain.in$ 
RewriteCond %{REQUEST_URI} !^/users
rewriterule ^(.*)$ http://mydomain.com/$1 [R=301,L]

所以,如果我没有被误解,我可以在没有“!”的情况下使用它。像这样。但我想我错过了一些东西。

    RewriteCond %{HTTP_HOST} ^mydomain.in$ [OR]
RewriteCond %{HTTP_HOST} ^www.mydomain.in$ 
RewriteCond %{REQUEST_URI} ^/folder/folder$
rewriterule ^(.*)$ http://mydomain.com/$1 [R=301,L]

然后在此刻我不知道的重定向要写。 感谢您的快速帮助。

1 个答案:

答案 0 :(得分:0)

您只需要重新排序指令,以便具有子文件夹的指令位于父重定向之前:

Redirect /folder/folder1 https://domain.com/target
Redirect /folder https://mydomain.com/therestoftheurl
相关问题