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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog