简体   繁体   中英

Undefined index: $_SERVER['HTTP_HOST'] Openshift scalable app

I have an scalable app in openshift and I'm having problems trying to access the PHP $_SERVER variables.

I am just trying to do " $domain = str_replace("www.", "", $_SERVER['HTTP_HOST']); " but got the error

undefined index HTTP_HOST

, this works fine in a normal app, but not in the scalable one.

My app have two main folders "frontend" and "backend" and I redirect all the data from the root folder to "frontend" with .htaccess :

RewriteRule    ^$    frontend/    [L]
RewriteRule    (.*) frontend/$1    [L]

Does anyone know how can I solve this error? Thanks

UPDATE : Just figured out that openshift has a bot that check the health of the application every two or three seconds, those access from the bot were causing the errors.

If HTTP_HOST is missing it either means the (a) the client is using a very old browser, (b) the bot doesn't send it or (c) the site is being accessed by it's IP Address rather than the domain name.

The manual implies this index may not always be set http://php.net/manual/en/reserved.variables.server.php Contents of the Host: header from the current request, if there is one.

如果缺少HTTP_HOST ,则意味着您的应用程序使用CLI运行。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM