簡體   English   中英

.htaccess重定向到沒有字符串的主URL

[英].htaccess redirects to main URL with no string

我需要協助。 我有這樣的鏈接。

http://www.example.com/a/exampl-xyz/every-one-have-story?xaf26a=98f5e0c5095a3f5c03c85ffdf2defc3b

我希望這些鏈接重定向到清理URL,如下所示:

http://www.example.com/a/exampl-xyz/every-one-have-story

如何做呢。 每個URL都有不同的字符串。

?xaf26a=98f5e0c5095a3f5c03c85ffdf2defc3b

具體情況:像這樣,從/.htaccess文件中的URL中刪除查詢字符串:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^.+$
RewriteRule ^a/exampl-xyz/every-one-have-story /a/exampl-xyz/every-one-have-story? [R=301,L]

隨着? 附加在URL上,不會將任何查詢字符串附加到結果URL。

對於常規URL,

例如,我們現在不需要任何URL參數,我的網站是一個裸露的URL,像http://www.example.com/abh/http://www.example.com/ab/cde/fghi .php ,我不再需要“ ?foo = bar&foo2 = bar2 ”,然后我用這個:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^.+$
RewriteRule ^ %{REQUEST_URI}? [R=301,L]

我想這會幫助你(進入你的.htaccess):

RewriteRule ^([^?] )\\?。 1美元[R = 301,L]

你可以試試這個。 但重新閱讀你的問題,目前還不清楚前后的真實差異。

RewriteEngine on
RewriteRule ^(.*)$ http://www.example.com/a/exampl-xyz/every-one-have-story/$1 [NC,L,R=301]

暫無
暫無

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

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