Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 基本301 rediret不工作_.htaccess - Fatal编程技术网

.htaccess 基本301 rediret不工作

.htaccess 基本301 rediret不工作,.htaccess,.htaccess,我正在尝试将一些旧的博客文章重定向到新的。这是我写的htaccess,放在根目录中。请记住,该站点现在位于linux服务器上,而不是windows 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 /pu

我正在尝试将一些旧的博客文章重定向到新的。这是我写的htaccess,放在根目录中。请记住,该站点现在位于linux服务器上,而不是windows

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

您可以在
重定向
语句的第一个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]

等等。

突出显示块和ctl-k,将其格式化为代码块,禁用链接:)因此,如果它不工作,它正在做什么?