.htaccess的重写从一个文件到另一个 [英] Htaccess rewrite from one file to another

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

问题描述

我需要重定向所有查询到文件1.PHP到文件2.PHP。所以,我需要的,如果有人会问1.PHP服务器会给他2.PHP。 1.PHP和2.PHP在同一个文件夹中。

I need to redirect all queries to file 1.php to file 2.php. So I need if somebody will ask 1.php server will give him 2.php. 1.php and 2.php are in the same folder.

RewriteEngine On
RewriteRule ^2.php 1.php

这code htaccess的不工作。哪里错了吗?

This code in htaccess doesn't work. Where is the mistake?

推荐答案

试试这个:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?[the folder]/1.php$
RewriteRule ^(/)?$ [the folder]/2.php [L]

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

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