2012-07-08 78 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被置于重写条件中),而不是像你所拥有的那样。