[英].htaccess Remove PHP get data from URL
我正在制作個人資料頁面,所以現在看起來像這樣
http://example.com/random/?user=Robert
我想做的是從URL中刪除?user=
,使頁面顯示為
http://example.com/random/Robert
我已經搜尋了,但找不到適合我的東西。 謝謝!
基於http://statichtml.com/2010/mod-rewrite-baseon-on-query-string.html,這應該可以解決問題:
RewriteCond %{QUERY_STRING} ^user=(.*)$ [NC]
RewriteRule ^random$ random/$1 [NC,L,R=301]
第一步是以http://example.com/random/Robert
形式創建所有鏈接,然后在文檔根目錄的htaccess文件中添加:
RewriteEngine On
RewriteRule ^random/(.+)$ /random/?user=$1 [L]
但是要處理301重定向到您的舊URL,您可以包括以下內容:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /random/\?user=([^\ ]+)
RewriteRule ^random/$ /random/%1 [R=301,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.