htaccess将一个文件重定向到另一个 [英] htaccess Redirect One File to Another
问题描述
我已经阅读了 this ,对于我来说这似乎太长了我的要求.
I've read this and this seems too long for my request.
并尝试了Redirect /index.php /index2.php
,但没有成功(内部服务器错误)
And tried Redirect /index.php /index2.php
but it didn't work (Internal Server error)
我想要的是将我的一些php文件重定向到索引.例如,我的索引文件为
What I want is to redirect some of my php files to index. For example, I've my index file as
header.php
header.php
content.php
content.php
footer.php
footer.php
,我想将对此文件的直接访问重定向到index.php. htaccess或其他任何方式都可以吗?
and I want to redirect direct access to this files to index.php. Is it possible with htaccess or any other way?
mysite.com/index.php确定 mysite.com/header.php重定向到404或索引或其他内容.
mysite.com/index.php OK mysite.com/header.php redirect to 404 or index or something else.
推荐答案
尝试:
RewriteEngine On
RewriteRule ^(header|content|footer)\.php - [L,R=404]
或
RewriteEngine On
RewriteRule ^(header|content|footer)\.php index.php [L,R=301]
这篇关于htaccess将一个文件重定向到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!