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
Php 通过htaccess删除扩展后,如何从旧url重定向到新url?_Php_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

Php 通过htaccess删除扩展后,如何从旧url重定向到新url?

Php 通过htaccess删除扩展后,如何从旧url重定向到新url?,php,.htaccess,mod-rewrite,redirect,Php,.htaccess,Mod Rewrite,Redirect,我正在使用以下代码片段删除页面的php扩展: RewriteEngine on rewritecond %{http_host} ^example.com [nc] rewriterule ^(.*)$ http://www.example.com/$1 [L,R=301] 现在我想从一个旧的页面到一个新的页面。类似“应该永久重定向(301)”的内容可以使用重定向匹配: RedirectMatch 301 ^/oldpage$ /newpage rewritecond%{http\u hos

我正在使用以下代码片段删除页面的php扩展:

RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [L,R=301]

现在我想从一个旧的页面到一个新的页面。类似“应该永久重定向(301)”的内容可以使用重定向匹配:

RedirectMatch 301 ^/oldpage$ /newpage

rewritecond%{http\u host}^example.com[nc]
rewriterule^(.*)$http://www.example.com/$1[L,R=301]
RedirectMatch 301^/oldpage$/newpage
这是我尝试过的方式,但它仍在打开oldpage。您可以将其放在重写引擎的上方联机尝试但没有成功。还是旧的一页打开了你还有其他的规则吗?就是上面问题中提到的。