如何通过htaccess将目录中的所有文件重定向到根目录中的另一个文件 [英] How to redirect all files in a directory to another in root via htaccess
本文介绍了如何通过htaccess将目录中的所有文件重定向到根目录中的另一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过.htaccess将站点上/user 目录中的所有文件(无论是否存在)重定向到根目录中名为 temp.php 的文件
I want to redirect all files (whether it exists or not) in /user directory on my site to a file named temp.php in root directory via .htaccess.
例如,如果用户输入 user/send.php 或 user/或 user/send (可能不存在)根本),所有都重定向到temp.php.
For example, if a user enter user/send.php or user/ or user/send (It may be that not Exists at all), all redirect to temp.php.
我该怎么做?
推荐答案
尝试一下:
RewriteEngine On
RewriteRule ^user/(.*)$ http://domain.com/temp.php [R,L]
这篇关于如何通过htaccess将目录中的所有文件重定向到根目录中的另一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文