試圖重定向:的.htaccess具有獨特的網址和查詢字符串重定向
/category/unique-name?foo=123&bar=&abc=
到:
http://www.example.com/new/page
大多數我讀過暗示對重定向多個查詢字符串模式的文章頁面。我只是在需要重定向的頁面之後。
我的最新嘗試是這樣的:
RewriteEngine On RewriteCond %{REQUEST_URI} ^/category/unique-name/$ RewriteCond %{QUERY_STRING} ^foo=123&bar=&abc=$ RewriteRule ^(.*) $ http://www.example.com/new/page? [R=301,L]
任何幫助,不勝感激!
UPDATE 2017年7月4日
感謝所有的建議。我試過所有的,有些導致了錯誤500,有些沒有效果。我列出這是其下面...
#無變化
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/category/unique-name$
RewriteCond %{QUERY_STRING} ^foo=123&bar=&abc=$
RewriteRule^http://www.example.com/new/page [R=301,L]
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/category/unique-name$
RewriteCond %{QUERY_STRING} ^foo=123&bar=&abc=$
RewriteRule^http://www.example.com/new/page [R=301,L]
#ERROR 500
RewriteEngine On
RewriteCond %{QUERY_STRING} ^foo=123&bar=&abc=$
RewriteRule ^/?category/unique-name/?$ $ http://www.example.com/new/page? [R=301,L]
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/category/unique-name/?$
RewriteCond %{QUERY_STRING} ^foo=123&bar=&abc=$
RewriteRule^$ http://www.example.com/new/page [R=301,END,QSD]
RewriteEngine On
RewriteCond %{QUERY_STRING} ^foo=123&bar=&abc=$
RewriteRule ^/?category/unique-name/?$ $ http://www.example.com/new/page [R=301,END,QSD]
我嘗試了下面的建議,並用我的結果更新了初始文章^^^ – gurtfrobe
「沒有工作」沒有幫助,您將不得不告訴我們更多的細節。 1.請發佈請求的_exact_ URL,以便從您的http服務器訪問日誌文件中獲得結果,2.發佈您在http服務器錯誤日誌文件中收到的條目,以防收到http狀態500. – arkascha
還請指定哪個版本您實際運行的http服務器的名稱。我懷疑這是一個很舊的。 – arkascha