htaccess仅将php文件重定向到另一个URL [英] htaccess redirection for php files only to another url

查看:75
本文介绍了htaccess仅将php文件重定向到另一个URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将特定文件夹内的php文件重定向到另一个URL,我使用的htacess文件既可以用于php文件,也可以与其他扩展名一起使用,对于我来说,我只希望将php文件重定向到新的url 就是htaccess:

I want to redirect my php files inside a specific folder to another url , the htacess file that i used is working for php files but also with other extensions and for my case i want only php files to be redirected to the new url that's the htaccess:

   RewriteEngine On
   RewriteCond %{HTTP_HOST} !^ml\.mysite1\.com/fr/test2/^(.*\.php)$
   RewriteRule (.*) http://mysite2.com/$1 [R=301,L]

我的问题是我如何只能重定向* .php而不重定向其他扩展名(jpg,png等)

My question is about how can i only redirect *.php and not other extension ( jpg, png etc )

谢谢

推荐答案

您需要更改第三行,使其仅与php扩展名的文件匹配.

Your third line needs to be changed so that it only matches files with the php extension.

RewriteRule (.*)\.php http://mysite2.com/$1.php [R=301,L]

这篇关于htaccess仅将php文件重定向到另一个URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆