dtkp51520 2015-01-20 21:34
浏览 59

为什么我的PHP不能直接访问我的西班牙语网站?

My code works for all my sites except the ones that begin with "es". Whenever I try to direct to those sites, it takes me back to index.html

This is my index.php code:

<?php 
/*
*
License: Creative Commons Attribution 3.0 Unported
License URL: http://creativecommons.org/licenses/by/3.0/
 *
 */
include "app/config.php";
include "app/detect.php";

if ($page_name=='') {
    include $browser_t.'/index.html';
    }
elseif ($page_name=='index.html') {
    include $browser_t.'/index.html';
    }
elseif ($page_name=='es/index.html') {
    include $browser_t.'/es/index.html';
}

else
    {
        include $browser_t.'/404.html';
    }

?>

I am linking my site so that you say what I mean. In the top right corner there is a hyperlink that says "Español" and when you click it, it's supposed to take you to a Spanish version of the page you're currently on. Instead, it simply takes you to the index tab anew and it changes the subdirectory, but my translated page does not appear.

Inside the config.php I have the following:

<?php
/*
 * 
License: Creative Commons Attribution 3.0 Unported
License URL: http://creativecommons.org/licenses/by/3.0/
 *
 */
$current_page_uri = $_SERVER['REQUEST_URI'];
$part_url = explode("/", $current_page_uri);
$page_name = end($part_url);
$email_id = "support@elitecomps.com";
?>

And I would add my detect.php code here but it is a large file and not the problem I am attempting to address so I will merely link it instead.

PS Everything is linked appropriately and I have triple checked everything. My only suspect left is my index.php which I am unsure of why.

  • 写回答

2条回答 默认 最新

  • doudou890510 2015-01-20 23:22
    关注
    $part_url = explode("/", $current_page_uri);
    $page_name = end($part_url);
    

    When the URL is "es/index.html", that code will assign $page_name to "index.html", since you're only interested in what is after the last /.

    One way could be to check the end of the string by using strrpos, e.g.

    if(strrpos("es/index.html", $current_page_uri) !== FALSE)
        // Go to spanish site
    else if(strrpos("index.html", $current_page_uri) !== FALSE)
        // Normal index page
    

    You could also check the second to last element in $part_url and check if it's "es", or any other language code.

    评论

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错