2012-07-08 76 views
0

我有一些URL重寫類似的東西:htaccess的重定向動態URL靜態URL

RewriteRule ^futbol-video/([^/]*)-([^-]*)\.html$ /html/video.php?text=$1&id=$2 [L] 

RewriteRule ^futbol-takimi/([^/]*)-([^-]*)\.html$ /html/takim.php?text=$1&id=$2 [L] 

我試圖重定向動態查詢到靜態頁面。我試過下面的東西,但每次都會發生內部服務器錯誤。我如何編寫規則表單301重定向?

首先,我已經試過:

RewriteRule ^futbol-video/([^/]*)-([^-]*)\.html$ /html/video.php?text=$1&id=$2 [R=301,L] 

RewriteRule ^futbol-takimi/([^/]*)-([^-]*)\.html$ /html/takim.php?text=$1&id=$2 [R=301,L] 

,但得到的內部服務器錯誤。

回答

0

我相信你正在處理查詢字符串不正確。

有關使用RewriteCond處理查詢字符串的一些示例,請參閱以下博客文章。

  1. http://www.simonecarletti.com/blog/2009/01/apache-query-string-redirects
  2. http://www.simonecarletti.com/blog/2009/01/apache-rewriterule-and-query-string/
  3. 從博客

例子:

#Keep original query (default behavior) 
RewriteRule ^page\.php$ /target.php [L] 
# from http://example.com/page.php?foo=bar 
# to http://example.com/target.php?foo=bar 

#Discard original query 
RewriteRule ^page\.php$ /target.php? [L] 
# from http://example.com/page.php?foo=bar 
# to http://example.com/target.php 

#Replace original query 
RewriteRule ^page\.php$ /target.php?bar=baz [L] 
# from http://example.com/page.php?foo=bar 
# to http://example.com/target.php?bar=baz 

#Append new query to original query 
RewriteRule ^page\.php$ /target.php?bar=baz [QSA,L] 
# from http://example.com/page.php?foo=bar 
# to http://example.com/target.php?foo=bar&bar=baz 

編輯 此外,如果你想從查詢字符串的URL重定向到一個靜態頁面中,帶有查詢字符串的url必須在重寫規則(o r被置於重寫條件中),而不是像你所擁有的那樣。