[英]PHP Location redirect contains file name index.html
When my simple apache webserver hits index.php it redirects to index.html however in the url instead of rooturl.com its example.com/index.html. 当我的简单apache网络服务器命中index.php时,它将重定向到index.html,但在url中而不是rooturl.com上将其example.com/index.html重定向。 Is there a simple way to fix this? 有简单的方法可以解决此问题吗?
header( 'Location: /index.hmtl') ;
www.example.com www.example.com
There can only be 1 default directory index file. 默认目录索引文件只能为1个。 Either http://example.com/
resolves as http://example.com/index.html
or http://example.com/index.php
. http://example.com/
解析为http://example.com/index.html
或http://example.com/index.php
。 You can't have both work at the same time. 您不能同时进行两项工作。
Instead of redirect to different index.html for different language, I think you should consider to directly include the HTML file. 我认为您应该考虑直接包含HTML文件,而不是重定向到不同语言的不同index.html。 For example, 例如,
<?php
// index.php
switch (some_get_user_language_func()) {
case 'en':
include './index.en.html';
case 'es':
include './index.es.html';
case 'fr':
include './index.fr.html';
default:
include './index.en.html';
}
Alternatively, you may try Apache's mod_negotiation to switch HTML file without the index.php file. 另外,您可以尝试使用Apache的mod_negotiation来切换没有index.php文件的HTML文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.