2016-06-15 423 views
0

我需要重定向我的舊的鏈接(刪除)在我的新的鏈接與.htaccess文件, 例如,的.htaccess與重定向URL參數在一個新的URL

From: http://www.example.com/page.php?value=2 (deleted) 
To: http://www.example.com/detail.php?d=150 

我試着用這個,但別沒有工作。如果檔案(page.php)不存在,則服務器會給我找不到404頁面。

我的.htaccess

<Files ~ "^\.(htaccess|htpasswd)$"> 
deny from all 
</Files> 
RewriteEngine On 
RewriteRule http://www.example.com/page.php?value=2 http://www.example.it/detail.php?d=150 [END,R=301] 
order deny,allow 

你能幫助我嗎?

+0

RewriteRule^http://www.example.com/page.php?value = 2 $ http://www.example.com/detail.php?d=150 [ R = 301,L] 試試這個 –

回答

0

RewriteRule directive沒有收到完整的URL,但相對URI的一部分,該指令的htaccess文件裏面。此外,它不會收到查詢參數,您將不得不通過RewriteCond directive訪問它們。所以,它應該是:

RewriteEngine On 
RewriteCond %{QUERY_STRING} ^value=2$ 
RewriteRule ^page.php$ /detail.php?d=150 [R=301,L,QSD]