[英]Htaccess redirect URL to another one and delete characters
I want an old website to be redirect to the new one, the URL looks like this: https://test.fr/directory/homepage.html
In my .htaccess file I have:
RedirectPermanent / https://google.com/`
但它的作用: https://google.com/directory/homepage.html
我想重定向到https://google.com/
并删除.com/
之后的所有内容,但我不知道如何。
只需使用重写模块:
RewriteEngine on
Rewrite ^ https://google.com/ [R=301,END]
显然,需要将重写模块加载到 http 服务器中。 这通常是这种情况,当然适用于所有托管服务提供商。
如果您只想在 http 主机内重定向特定的 URL ,那么应该这样做:
RewriteEngine on
Rewrite ^/?directory/homepage\.html$ https://google.com/ [R=301,END]
您可以在分布式配置文件(“.htaccess”)中实现此类指令。 不过,如果您有权访问,您应该更喜欢实际的 http 服务器的主机配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.