2014-01-07 256 views
1

我想将子/子文件夹url重定向到特定的URL。使用htaccess将url重定向到子/子文件夹

它的工作原理与普通重定向,如:

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

但我需要很多文件夹/文件夹1或文件夹/文件夹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] 

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

回答

0

你只需要重新整理你的指令,以便家长重定向前的一个子文件夹来:

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