試圖重寫具有多個參數的頁面的URL,並且其中一個參數包含多個單詞(在提交時用空格分隔)。用多字字符串(帶mod_rewrite)重寫包含多個參數的URL
這將是URL:www.ABCD.com/store/itemsDescr.php?categ=headbands & ID = 123 &名=棕色%20with%20black
我希望URL顯示像這樣: www.ABCD.com/store/headbands/123/brown-with-black
我想這一點,但沒有奏效:
RewriteCond %{QUERY_STRING} ^categ=([^&]+) [NC,OR]
RewriteCond %{QUERY_STRING} &categ=([^&]+) [NC]
RewriteRule ^store/itemsDescr\.php$ $0/%1
RewriteCond %{QUERY_STRING} ^id=([^&]+) [NC,OR]
RewriteCond %{QUERY_STRING} &id=([^&]+) [NC]
RewriteRule ^store/itemsDescr\.php/[^/]+$ $0/%1
RewriteCond %{QUERY_STRING} ^name=([^&]+) [NC,OR]
RewriteCond %{QUERY_STRING} &name=([^&]+) [NC]
RewriteRule ^store/itemsDescr\.php/([^/]+/[^/]+)$ http://www.ABCD.com/store/$1/%1/? [L,QSA,NC]
任何幫助將是非常appre ciated!
注意:這個規則我想實現之前,我已經有另一頁的其他規則,在情況下,它可以產生衝突:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(store)/index\.php\?categ=([^\s]+) [NC]
RewriteRule^/%1/%2? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^store/(.+?)/?$ /store/index.php?categ=$1 [L,QSA,NC]
你是什麼意思:'但是我不想重定向。 – anubhava
這實際上是一個錯字。刪除。我只是想讓網址看起來更加SEO友好... – samyb8
好吧我會採取刺。 (這是多一點參與) – anubhava