2012-10-29 88 views
0

我正在嘗試將一些舊的博客文章重定向到新的。這是我編寫並放置在根目錄中的htaccess。請記住,該網站現在在Linux服務器上,而不是Windows。基本301重定向不起作用

redirect 301 /public/recipesdetl.aspx?id=1888 http://www.mysite.com/recipes/ 
redirect 301 /public/recipesdetl.aspx?id=2025 http://www.mysite.com/recipes/?p=405 
redirect 301 /public/recipesdetl.aspx?id=2682 http://www.mysite.com/recipes/?p=549 
redirect 301 /public/recipesdetl.aspx?id=2152 http://www.mysite.com/recipes/?p=309 
redirect 301 /public/recipesdetl.aspx?id=1398 http://www.mysite.com/recipes/?p=817 
redirect 301 /public/recipesdetl.aspx?id=1908 http://www.mysite.com/recipes/?p=155 
redirect 301 /public/recipesdetl.aspx?id=2162 http://www.mysite.com/recipes/?p=317 
redirect 301 /public/recipesdetl.aspx?id=1889 http://www.mysite.com/recipes/?p=145 
redirect 301 /public/recipesdetl.aspx?id=1951 http://www.mysite.com/recipes/?p=808 
redirect 301 /public/recipesdetl.aspx?id=2032 http://www.mysite.com/recipes/?p=238 
redirect 301 /public/recipesdetl.aspx?id=2101 http://www.mysite.com/recipes/?p=269 
redirect 301 /public/recipesdetl.aspx?id=2147 http://www.mysite.com/recipes/?p=304 
redirect 301 /public/recipesdetl.aspx?id=2563 http://www.mysite.com/recipes/?p=449 
redirect 301 /public/recipesdetl.aspx?id=2043 http://www.mysite.com/recipes/?p=243 
redirect 301 /public/recipesdetl.aspx?id=2224 http://www.mysite.com/recipes/?p=361 
redirect 301 /public/recipesdetl.aspx?id=2151 http://www.mysite.com/recipes/?p=308 
+0

突出塊和CTL -k將其格式化爲代碼塊,禁用鏈接:) –

+0

因此,如果它不工作,它有什麼或不是在幹什麼? –

回答

0

可以包括在Redirect語句的第一個URI路徑查詢字符串,你需要使用mod_rewrite的%{QUERY_STRING}變量:

RewriteEngine On 

RewriteCond %{QUERY_STRING} ^id=1888$ 
RewriteRule ^/?public/recipesdetl.aspx$ http://www.mysite.com/recipes/ [L,R=301] 

RewriteCond %{QUERY_STRING} ^id=2025$ 
RewriteRule ^/?public/recipesdetl.aspx$ http://www.mysite.com/recipes/?p=405 [L,R=301] 

RewriteCond %{QUERY_STRING} ^id=2682$ 
RewriteRule ^/?public/recipesdetl.aspx$ http://www.mysite.com/recipes/?p=549 [L,R=301] 

RewriteCond %{QUERY_STRING} ^id=2152$ 
RewriteRule ^/?public/recipesdetl.aspx$ http://www.mysite.com/recipes/?p=309 [L,R=301]