簡體   English   中英

如何創建一個301重定向到HTTPS的.htaccess文件,將尾隨斜杠從URL末尾重定向到non,並刪除.php而不會發生沖突?

[英]How can I create a .htaccess file that 301 redirects to HTTPS, redirects trailing slash from end of URL to non and removes .php without conflicts?

我已經嘗試了好幾個小時了,創建這個.htaccess文件的過程並不順利。

我已經重新開發了網站,而我的SEO遍地都是。 為了Google和用戶的利益,我需要一個.htaccess文件,該文件應:

  • http://example.com/*重定向到https://example.com/*
  • *.example.com/*.php重定向到https://example.com/*
  • *.example.com/*/重定向到https://example.com/*

因此,為了明確起見,強制使用SSL,並以Google友好(301重定向)的方式刪除結尾的斜杠和.php擴展名。 或以上的任何組合。

應該這樣做-對於所有列出的情況

Redirect permanent / https://secure.example.com/

參考: https : //wiki.apache.org/httpd/RedirectSSL

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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