88 个回复 | 最后更新于 2017-12-12
2016-07-08   #20

回复#18 @lincanbin :

还是不行 是不是我其他的地方有问题呢 ? tag 404 ,点用户名也 404 

2016-07-08   #21

回复 #0 @圖騰_totem :

nginx?

2016-07-08   #22

回复#21 @lincanbin :

客服回我的: 我们服务器是前端nginx,反向代理apache,实际是apache在处理
可以直接当做lamp即可 。

然后我该怎么操作。


2016-07-08   #23

回复 #0 @圖騰_totem :

没道理,你架构跟我一样。

2016-07-08   #24

回复#23 @lincanbin :

直接装完了是不是还要其他的配置的呢 ? 我用的是虚拟主机。

2016-07-08   #25

回复 #24 @圖騰_totem :

不需要

2016-07-08   #26

回复#25 @lincanbin :

http://yetanloushi.com/ 

你看看是哪有问题么?


2016-07-08   #27

回复 #0 @圖騰_totem :

外面看不出,把你index.php发过来。

2016-07-08   #28

回复#27 @lincanbin :

<?php
require(__DIR__ . '/common.php');

$HTTPMethod = $_SERVER['REQUEST_METHOD'];
if (!in_array($HTTPMethod, array('GET', 'POST', 'HEAD', 'PUT', 'DELETE', 'OPTIONS'))) {
	exit('Unsupport HTTP method');
}
if ($Config['WebsitePath']) {
	$WebsitePathPosition = strpos($RequestURI, $Config['WebsitePath']);
	if ($WebsitePathPosition !== 0) {
		exit('WebsitePath Error!');
	} else {
		$ShortRequestURI = substr($RequestURI, strlen($Config['WebsitePath']));
	}
} else {
	$ShortRequestURI = $RequestURI;
}
$NotFound = true;
$HTTPParameters = array();
if (in_array($HTTPMethod, array('PUT', 'DELETE', 'OPTIONS'))) {
	parse_str(file_get_contents('php://input'), $HTTPParameters);
}
$Routes = array();

//Support HTTP Method: GET / POST / PUT / DELETE / OPTIONS
//这里是Routes Start

$Routes['GET']['/']                                                                        = 'home';
$Routes['POST']['/']                                                                       = 'home'; //Delete later
$Routes['GET']['/dashboard']                                                               = 'dashboard';
$Routes['POST']['/dashboard']                                                              = 'dashboard';
$Routes['GET']['/favorites(/page/(?<page>[0-9]+))?']                                       = 'favorites';
$Routes['GET']['/forgot']                                                                  = 'forgot';
$Routes['POST']['/forgot']                                                                 = 'forgot';
$Routes['GET']['/goto/(?<topic_id>[0-9]+)-(?<post_id>[0-9]+)']                             = 'goto';
$Routes['POST']['/json/(?<action>[0-9a-z_\-]+)']                                           = 'json';
$Routes['GET']['/json/(?<action>[0-9a-z_\-]+)']                                            = 'json';
$Routes['GET']['/login']                                                                   = 'login';
$Routes['POST']['/login']                                                                  = 'login';
$Routes['POST']['/manage']                                                                 = 'manage';
$Routes['GET']['/new']                                                                     = 'new';
$Routes['POST']['/new']                                                                    = 'new';
$Routes['GET']['/notifications']                                                           = 'notifications';
$Routes['GET']['/oauth-(?<app_id>[0-9]+)']                                                 = 'oauth';
$Routes['POST']['/oauth-(?<app_id>[0-9]+)']                                                = 'oauth';
$Routes['GET']['/page/(?<page>[0-9]+)']                                                    = 'home';
$Routes['POST']['/page/(?<page>[0-9]+)']                                                   = 'home'; //Delete later
$Routes['GET']['/register']                                                                = 'register';
$Routes['POST']['/register']                                                               = 'register';
$Routes['GET']['/reply']                                                                   = 'reply';
$Routes['POST']['/reply']                                                                  = 'reply';
$Routes['GET']['/reset_password/(?<access_token>.*?)']                                     = 'reset_password';
$Routes['POST']['/reset_password/(?<access_token>.*?)']                                    = 'reset_password';
$Routes['GET']['/robots.txt']                                                              = 'robots';
$Routes['GET']['/search.xml']                                                              = 'open_search';
$Routes['GET']['/search/(?<keyword>.*?)(/page/(?<page>[0-9]*))?']                          = 'search';
$Routes['GET']['/settings']                                                                = 'settings';
$Routes['POST']['/settings']                                                               = 'settings';
$Routes['GET']['/sitemap-(?<action>topics|pages|tags|users|index)(-(?<page>[0-9]+))?.xml'] = 'sitemap';
$Routes['GET']['/statistics']                                                              = 'statistics';
$Routes['GET']['/t/(?<id>[0-9]+)(-(?<page>[0-9]*))?']                                      = 'topic';
$Routes['POST']['/t/(?<id>[0-9]+)(-(?<page>[0-9]*))?']                                     = 'topic'; //Delete later
$Routes['GET']['/tag/(?<name>.*?)(/page/(?<page>[0-9]*))?']                                = 'tag';
$Routes['GET']['/tags/following(/page/(?<page>[0-9]*))?']                                  = 'favorite_tags';
$Routes['GET']['/tags(/page/(?<page>[0-9]*))?']                                            = 'tags';
$Routes['GET']['/u/(?<username>.*?)']                                                      = 'user';
$Routes['GET']['/users/following(/page/(?<page>[0-9]*))?']                                 = 'favorite_users';
$Routes['GET']['/upload_controller']                                                      = 'upload_controller';
$Routes['POST']['/upload_controller']                                                      = 'upload_controller';
$Routes['GET']['/view-(?<view>desktop|mobile)']                                            = 'view';

//这里是Routes End


foreach ($Routes as $Method => $SubRoutes) {
	if ($Method === $HTTPMethod) {
		$ParametersVariableName = '_' . $Method;
		foreach ($SubRoutes as $URL => $Controller) {
			if (preg_match("#^" . $URL . "$#i", $ShortRequestURI, $Parameters)) {
				$NotFound = false;
				$Parameters = array_merge($Parameters, $HTTPParameters);
				//var_dump($Parameters);
				foreach ($Parameters as $Key => $Value) {
					if (!is_int($Key)) {
						$$ParametersVariableName[$Key] = urldecode($Value);
						$_REQUEST[$Key] = urldecode($Value);
					}
				}
				//$MicroTime = explode(' ', microtime());
				//echo number_format(($MicroTime[1] + $MicroTime[0] - $StartTime), 6) * 1000;
				$UrlPath = $Controller;
				break 2;
			}
		}
		break;
	}
}

if ($NotFound === true) {
	require(__DIR__ . '/404.php');
	exit();
}

if ($Config['MobileDomainName'] && $_SERVER['HTTP_HOST'] != $Config['MobileDomainName'] && $CurView == 'mobile' && !$IsApp && $UrlPath != 'view') {
	//如果是手机,则跳转到移动版
	header("HTTP/1.1 302 Moved Temporarily");
	header("Status: 302 Moved Temporarily");
	header('Location: ' . $CurProtocol . $Config['MobileDomainName'] . $RequestURI);
	exit();
}

require(__DIR__ . '/controller/' . $UrlPath . '.php');


2016-07-08   #29

回复#5 @新手一枚 :

你是怎么解决的呀 。

2016-07-09   #30

回复#27 @lincanbin :

我现在index.php 这么修改的 

foreach ($Parameters as $Key => $Value) {
    if (!is_int($Key)) {
        if($ParametersVariableName == '_GET'){
            $_GET[$Key] = urldecode($Value);
        }else if($ParametersVariableName == '_POST'){
            $_POST[$Key] = urldecode($Value);
        }
    //$$ParametersVariableName[$Key] = urldecode($Value);
        $_REQUEST[$Key] = urldecode($Value);
    }
}


2016-07-11   #31

回复#27 @lincanbin :

同样的问题 git clone  重新更新了 都不行   我也是NGINX

2016-07-11   #32

回复#31 @kidvnet :

按照我上边的修改下  你试试。

2016-07-11   #33

回复#32 @圖騰_totem :

试了你的方法 的确可以了!  非常感谢!

2016-07-12   #34

回复#25 @lincanbin :

你来看看 , 我们两个都遇到了这个问题了 

我让朋友看的 他说 $UserName = Request('Get', 'username'); GET 获取不到内容同 所以404 就按着的这个方法改了

 if($ParametersVariableName == '_GET'){
            $_GET[$Key] = urldecode($Value);
        }else if($ParametersVariableName == '_POST'){
            $_POST[$Key] = urldecode($Value);
        }

但是我感觉破坏了你的代码。

2016-07-12   #35

回复#34 @圖騰_totem :

没道理啊,照理来说我那个代码可以设置$_GET的值的。

2016-07-12   #36

回复#35 @lincanbin :

我跟 kidvnet 都遇到这个问题了,他也按照我的方法改的。 这么说确实很奇怪。

2016-07-12   #37

回复#36 @圖騰_totem :

可能部分服务器不支持动态指定变量名?

2016-07-12   #38

回复#37 @lincanbin :

可惜我不会PHP,我也是头一次听说,又长见识了。不错不错。

2016-07-12   #39

回复#37 @lincanbin :

可能他们用的是低版本的PHP。

登录后方可回帖

登 录
信息栏

Carbon Forum是一个基于话题的高性能轻型PHP论坛

下载地址:Carbon Forum v5.9.0
QQ群:12607708(QQ我不常上)

donate

手机支付宝扫描上方二维码可向本项目捐款

粤公网安备 44030602003677号
粤ICP备17135490号

Loading...