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 htaccess 301使用通配符重定向到单个页面_.htaccess_Redirect - Fatal编程技术网

.htaccess htaccess 301使用通配符重定向到单个页面

.htaccess htaccess 301使用通配符重定向到单个页面,.htaccess,redirect,.htaccess,Redirect,我们接管了一个网站,在htm中完成的旧站点根目录中有大约1万亿个页面,需要注销。我想使用通配符从页面重定向到新站点根目录中的index.php。页面命名结构的示例如下: oldpage_dees.htm oldPage_dat.htm oldPage_deeudderting.htm 等等。如上所述,我需要将它们重定向到根目录中的index.php。通过这里的示例和讨论,我尝试了: RewriteEngine On RewriteRule ^/oldpage_([\w]*).htm$ /ind

我们接管了一个网站,在htm中完成的旧站点根目录中有大约1万亿个页面,需要注销。我想使用通配符从页面重定向到新站点根目录中的index.php。页面命名结构的示例如下:

oldpage_dees.htm
oldPage_dat.htm
oldPage_deeudderting.htm
等等。如上所述,我需要将它们重定向到根目录中的index.php。通过这里的示例和讨论,我尝试了:

RewriteEngine On
RewriteRule ^/oldpage_([\w]*).htm$ /index.php  [R=301,L]
但我有一个404错误


有什么建议吗?提前谢谢

由于
.htaccess
是目录级配置文件,您不需要指定正斜杠,我认为这将完成以下工作:

   RewriteEngine On
   RewriteRule ^oldpage_([\w]*).htm$ index.php  [R=301,L]

同时,您可以使用以下方法调试重写规则。

作为
。htaccess
是目录级配置文件,您不需要指定正斜杠,我认为这可以完成此工作:

   RewriteEngine On
   RewriteRule ^oldpage_([\w]*).htm$ index.php  [R=301,L]
同时,您可以使用以下命令调试重写规则