![](/img/trans.png)
[英].htaccess redirect from subdirectory to parent directory file but maintain url path
[英]htaccess redirect url to parent directory
我在我的网站上遇到问题。 Google 将许多此类 URL 编入索引:
http://example.com/folder/url1.php/url2.php
那么,我怎样才能重定向到我原来的 URL,在这种情况下是:
http://example.com/folder/url1.php
文件夹中还有另一个文件夹2,只有在 url1.php 后附加另一个 url 时才会重定向
坦率地说,我对这个htaccess重定向真的很陌生,我以前从未使用过这个。
因此,任何帮助将不胜感激。
您可以使用RedirectMatch
指令来重定向您的 URL。
在您的 htaccess 文件的顶部,添加以下行:
RedirectMatch 301 ^/folder/([^/]+)/([^/]+)\.php$ https://example.com/folder/$1
要重定向特定/单个 URI,您可以使用
RedirectMatch 301 ^/folder/file.php/file.php$ https://example.com/folder/file.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.