doubishi8303 2014-06-13 11:49
浏览 18

PHP只打开索引文件,说其他人不存在,即使他们这样做

So, I am making a website and I am putting it together with includes in index.php file. The problem is that website opens and shows first page perfectly, but none of the languages links work! Here is my code:

Index file:

<?php
    $languages = array("eng","lat");
    $sections = array("home");
    $sectionTitles = array("eng" =>array(
    "WHERE CAN YOU FIND US?",
    "WHO ARE WE?",
    "CONTACTS",
    ), 
        "lat"=>array(
                "KUR MŪS ATRAST?",
            "PAR MUMS",
            "KONTAKTI",
            ));

$lang = "lat";
$section = "home";

$content = explode("/", $_SERVER['REQUEST_URI']);

if (!empty($content[1]) && (in_array($content[1], $languages))) { $lang = $content[1];}
if (!empty($content[2]) && (in_array($content[2], $sections))) { $section = $content[2];}
$sectionTitles = $sectionTitles[$lang];

include ("header.php");
include ("$lang/$section.php");
include ("footer.php");

?>

.htaccess file:

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !\.(php|css|js|gif|png|jpe?g|pdf|eot|svg|ttf|woff|ico)$
    RewriteRule (.*)$ /index.php [L]

link in my header file:

    <a href="/eng/<?=$section?>">eng</a>

Thank you in advance!

  • 写回答

1条回答 默认 最新

  • dongzhuo5425 2014-06-13 12:10
    关注

    Change htaccess file to

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !\.(php|css|js|gif|png|jpe?g|pdf|eot|svg|ttf|woff|ico)$
    RewriteRule (.*)$ /index.php?_url=$1 [L]
    

    Then you can use

    $content = explode("/", $_GET['_url']);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算