Php htaccess将动态url重定向到静态url
我有一些url重写如下:Php htaccess将动态url重定向到静态url,php,apache,.htaccess,redirect,Php,Apache,.htaccess,Redirect,我有一些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 [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]
但是获取内部服务器错误 我认为您处理查询字符串的方式不正确 有关使用RewriteCond处理查询字符串的一些示例,请参阅以下博客文章 博客中的示例:
#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必须在重写规则中位于第一位(或置于重写条件下),而不是第二位