• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

想用PATH_INFO功能。但是不知道应该加到哪里?解决办法

php 搞代码 3年前 (2022-01-24) 12次浏览 已收录 0个评论

想用PATH_INFO功能。但是不知道应该加到哪里?
这是一个查看网页源代码的功能
网址是这样的
http://www.vipcha.net/5/
我想实现的功能是这样的
http://www.vipcha.net/5/www.baidu.com //在原来的基础上增加一个网址。

代码如下: 请高手指点一下。谢谢

PHP code

<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php$hu = 'yuan';@require_once('global.php');$domain = $_POST['domain'];if($domain){    is_domain($domain) or exit( "<script language=javascript>alert('请输入正确的域名!');location.href='index.php';</script>");    $content = @file_get_contents("http://".$domain);    @require_once('cache.php');    if(file_exists("cache/cache.php")){        @require_once("cache/cache.php");        $urls = filehave($urls,$domain);    }else{        $urls = fileno($domain);    }    writeover("cache/cache.php","<?php\r\n\$urls=".vvar_export($urls).";\r\n?>");}?><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>网页源代码查看器</title>"/> <textarea id="content" name="content" style="width:750px;height:850px;border:1px solid #c5e2f2;overflow:visible" cols="20" rows="65"><?php echo $content;?></textarea></div>最近查询<table><tr><td align="left"><?php@require_once('cache/cache<i>·本2文来源gaodai$ma#com搞$代*码网2</i><strong>搞gaodaima代码</strong>.php');if($urls){foreach ($urls as $key=>$v){    echo "".$urls[$key]."  ";}}?></td></tr></table> 

——解决方案——————–
表单不要提交

用js跳转

服务器接受参数,启用rewrite
——解决方案——————–

PHP code

<?php//在哪都能加$path_parts = pathinfo($_SERVER['REQUEST_URI']);print_r($path_parts);?>
------解决方案--------------------
网址是这样的 www.vipcha.net/5/
那么你实际访问的是 www.vipcha.net/5/index.php
如果那个 5/ 适当做参数时 那要这样才行 www.vipcha.net/index.php/5
这就是 PATH_INFO

我想实现的功能是这样的
www.vipcha.net/5/www.baidu.com
这就需要 urlrewrite 了,因为需要隐藏php文件名


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:想用PATH_INFO功能。但是不知道应该加到哪里?解决办法
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址