Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 请求uri并数组这些东西_Php_Uri - Fatal编程技术网

Php 请求uri并数组这些东西

Php 请求uri并数组这些东西,php,uri,Php,Uri,我有一个代码需要帮助 if ($_SERVER['REQUEST_URI'] == '/testmore/' || $_SERVER['REQUEST_URI'] == '/testmore/home') { $_SERVER['REQUEST_URI'] = '/testmore/index'; } echo $_SERVER['REQUEST_URI']; echo '<br>'; $page = $_SERVER['REQUEST_URI'];

我有一个代码需要帮助

    if ($_SERVER['REQUEST_URI'] == '/testmore/' || $_SERVER['REQUEST_URI'] == '/testmore/home') { $_SERVER['REQUEST_URI'] = '/testmore/index'; }

    echo $_SERVER['REQUEST_URI']; echo '<br>';


    $page = $_SERVER['REQUEST_URI'];

    function dostuff($pagesC) { echo 'yes!<br>'; echo $pagesC.'<br>'; }


    $pageArray = Array('index', 'login'); 

$directory = '/testmore/'; // Directory if in one. Otherwise, leave it as '/'.  

    $uriArray = explode('/', strstr($_SERVER['REQUEST_URI'], $directory));
      if (in_array($uriArray[0], $pageArray)) {
        dostuff($uriArray[0]); } else {
        echo '404'; }
if($_服务器['REQUEST_URI']='/testmore/'|$_服务器['REQUEST_URI']='/testmore/home'){$_服务器['REQUEST_URI']='/testmore/index'}
echo$_服务器['REQUEST_URI'];回声“
”; $page=$\u服务器['REQUEST\u URI']; 函数dostuff($pagesC){echo'yes!
';echo$pagesC.
';} $pageArray=Array('index','login'); $directory='/testmore/';//目录(如果在一个目录中)。否则,将其保留为“/”。 $URARRAY=explode('/',strstrstr($_SERVER['REQUEST_URI'],$directory)); if(在数组中($URARRAY[0],$pageArray)){ dostuff($uriArray[0]);}其他{ 回音'404';}
它使用URI请求,并从
http://link.com/index.php?page=$VARIABLE
http://link.com/variable

我已经完成了所有的
.htaccess
并且正在工作,这不会是一个问题。
问题是当我键入
http://link.com/testmore/index
它不会显示指定的页面,而是404页面。

您不必在PHP页面中执行任何操作。页面无法工作的原因是.htaccess代码不正确。试试这个:

RewriteRule ^(.*?)/(.*?)$ index.php?page=$1&sub=$2 [L]
RewriteRule ^(.*?)$ index.php?page=$1 [L]
以上内容将屏蔽重定向
http://link.com/testmore/index
http://link.com/index.php?page=testmore&sub=index
。它还将重定向
http://link.com/variable
http://link.com/index.php?page=variable

$uriArray = explode('/', $_SERVER['REQUEST_URI']);
if (in_array($uriArray[1], $pageArray)){
     dostuff($uriArray[1]);
else
     echo '404';

我不知道你在说什么,但我想要的是
http://link.com/testmore/index
atm不折不扣。OP中的代码是my index.php for/testmore/Edit your.htaccess文件以使用上述代码,您不需要php文件中的所有向导代码……好的,如果您没有查看代码,我没有任何
GET
请求。我只是想用
REQUEST\u URI
来制作
http://link.com/testmore/variable
而不是使用
GET
。我也尝试过使用
GET
,但从未奏效。我现在要求的是让404显示正确的页面。否则一切都很好,我加了。但是我不知道你想做什么。我知道了,它是
$uriArray=explode($directory,$\u SERVER['REQUEST\u URI')