簡體   English   中英

Htaccess 將 URL 重定向到另一個並刪除字符

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM