簡體   English   中英

如何從網址中刪除尾部斜杠

[英]how can i remove trailing slashes form the url

我在URL末尾有斜杠的問題。 我在線檢查URL重定向,結果顯示我的頁面上有太多的重定向,所以我需要減少那些重定向,我的鏈接有以下結果

https://example.com/xyz/pqr
302 Found
https://example.com/xyz/pqr/
302 Found
https://example.com/xyz/pqr//
302 Found
https://example.com/xyz/pqr///
302 Found
https://example.com/xyz/pqr////
302 Found
https://example.com/xyz/pqr/////
302 Found
https://example.com/xyz/pqr//////
302 Found
https://example.com/xyz/pqr///////
302 Found
https://example.com/xyz/pqr////////
302 Found
https://example.com/xyz/pqr/////////
302 Found
https://example.com/xyz/pqr//////////
302 Found
https://example.com/xyz/pqr///////////
302 Found
https://example.com/xyz/pqr////////////
302 Found
https://example.com/xyz/pqr/////////////
302 Found
https://example.com/xyz/pqr//////////////
302 Found
https://example.com/xyz/pqr///////////////
302 Found
https://example.com/xyz/pqr////////////////
302 Found
https://example.com/xyz/pqr/////////////////
302 Found
https://example.com/xyz/pqr//////////////////
302 Found
https://example.com/xyz/pqr///////////////////
302 Found

我怎么能解決這個問題? 我不知道我哪里錯了.. !! 任何幫助都是有意義的。 提前致謝。

這是我的htaccess代碼:

RewriteEngine on
RewriteCond %{QUERY_STRING} p=3842
RewriteRule ^ /? [R=301,L]

這就是我在htaccess代碼中的所有內容,其余的只是301重定向,僅此而已...... !!

要使用.htaccess刪除尾部斜杠,您可以使用:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [R=301,L]

暫無
暫無

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

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