Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
301使用.htaccess重定向php文件_Php_.htaccess_Redirect - Fatal编程技术网

301使用.htaccess重定向php文件

301使用.htaccess重定向php文件,php,.htaccess,redirect,Php,.htaccess,Redirect,我们重新设计了一个网站,有些页面已经不存在了。我对大多数旧页面进行了301重定向,但我不想让所有这些旧页面都保留在我的文件夹中,而是想重定向.htaccess文件中的所有内容。下面是我目前的整个.htaccess文件。将html文件重定向到php文件可以正常工作,但是尝试从php文件重定向到php文件是不起作用的。我试着将url的第一部分(到.com)从新页面上删除,但仍然出现404错误。我尝试了多个其他页面,每次都得到了相同的结果,从html到php都可以,但从php到php却不行。有什么建议

我们重新设计了一个网站,有些页面已经不存在了。我对大多数旧页面进行了301重定向,但我不想让所有这些旧页面都保留在我的文件夹中,而是想重定向.htaccess文件中的所有内容。下面是我目前的整个.htaccess文件。将html文件重定向到php文件可以正常工作,但是尝试从php文件重定向到php文件是不起作用的。我试着将url的第一部分(到.com)从新页面上删除,但仍然出现404错误。我尝试了多个其他页面,每次都得到了相同的结果,从html到php都可以,但从php到php却不行。有什么建议吗

Options +FollowSymLinks
RewriteEngine on
Redirect 301 /folder1/page1.php http://www.example.com/folder2/page2.php
Redirect 301 /folder1/page1.html http://www.example.com/folder2/page2.php
编辑:

获取folder1中的所有内容并重定向到folder2


然后将所有html文件扩展名重写为php

soudln是不是
RedirectMatch 301 folder1/(*)folder2/$1
?很好,我解决了:)对不起,我是个新手,你能解释一下这一切意味着什么吗?我不希望从文件夹1到文件夹2的所有内容,我也不希望我的网站上的所有html文件都重写为php。还有别的办法吗?那么我想我误解了你的问题。你只是想重定向这两个URL吗?
RewriteEngine On
RedirectMatch 301 folder1/(.*) folder2/$1
RewriteRule ^(.*)\.html$ $1.php [L]