2

Host: Amazon Web Services

Domain: Godaddy

SSL: Godaddy

Framework: Laravel 4.2

PHP: PHP5.6

Apache: Apache 2.4.16

File located: /var/www/html/test

My code:

$api_request = 'https://'.apache_getenv("HTTP_HOST") . apache_getenv("REQUEST_URI");

Error: PHP Fatal error: Call to undefined function apache_getenv()

It looks like it doesn't exist.

Laravel App Located at: html. Then another two folders with laravel: test and live.

  • html/ (Laravel app landing page)
    • app/
    • bootstrap/
    • packages/
    • public/
    • vendor/
    • test/ (Laravel app)
    • live/ (Laravel app)
    • index.php

It works properly at html app. but in test app the function doesn't exist anymore.

9
  • Is your Server API the Apache handler? Commented Nov 18, 2015 at 10:27
  • @ÁlvaroGonzález Server API Apache 2.0 Handler Commented Nov 18, 2015 at 10:30
  • What's wrong with using $_SERVER? Commented Nov 18, 2015 at 10:34
  • maybe interesting? getenv — Gets the value of an environment variable. Commented Nov 18, 2015 at 11:37
  • @JonStirling I tried. Gives me the error of undefined index HTTP_HOST Commented Nov 19, 2015 at 0:38

2 Answers 2

2

Can you please try

$_SERVER['HTTP_HOST'] and  $_SERVER['REQUEST_URI']

In place of apache_getenv some times apache does not allow you to access the functions without the module activation.

Hope this will help you.

Sign up to request clarification or add additional context in comments.

3 Comments

I tried. Gives me the error of undefined index HTTP_HOST
check my answer with follow up question. this could help a lot of people hehe
@MarlonBuendia - Seriously, all symptoms suggest you are running PHP from the command line, not through a web server.
1

Looks like apache_getenv is disabled in your php.ini

Enable it by

Edit php.ini (By default /etc/php.ini)

Remove apache_getenv from disable_functions section

save and exit.

restart apache/php handler.

6 Comments

what word should I search in php.ini?
i found it but its empty disable_functions =
There was nothing to erase.
Are you using a shared hosting environment? If yes then there might be override in server's main php.ini.
check my answer with follow up question. this could help a lot of people hehe
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.