php $_SERVER[‘HTTP_HOST’] is always same domain no matter from which domain i request

Right now for example i have this domains:

I try to use cURL from,, to and block the cURL request.

Example code file on

  $ch = curl_init();
  if (FALSE === $ch){
    throw new Exception('failed to initialize');
  curl_setopt($ch, CURLOPT_URL,"");
  curl_setopt($ch, CURLOPT_POST, TRUE);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $msg);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  $p_result = curl_exec($ch);
  if (FALSE === $p_result) {
    throw new Exception(curl_error(), curl_errno());
  } else{
    return $p_result;
}catch(Exception $e) {
  trigger_error(sprintf('Curl failed with error #%d: %s',$e->getCode(), $e->getMessage()),E_USER_ERROR);

Example code file on

  $domains = array(""); //blacklisted

  $domainIsValid = array_filter($domains, function ($var) use ($_SERVER) {
        return strpos($var, $_SERVER['HTTP_HOST']) !== false;

$_SERVER['HTTP_HOST'] // is always even if i request from

Do i missing something? is it Apache server configuration?

Host: DigitalOcean Ubuntu 16.04 with Apache server.

Symfony4 does not get Environment Varbiables from vHost Configuration

I’m currently setting up an Webserver on a RaspberryPi with Raspbian 9 and want to deploy a productive Symfony4 Webpage on it.

For that case I created a vHost File in Apache2 with the needed Environment-Variables in it. But as I’m executing “composer install –no-dev” (because I don’t want to use dotenv) I’m getting the error “PHP Fatal error: Uncaught RuntimeException: APP_ENV environment variable is not defined. You need to define environment variables for configuration or add “symfony/dotenv” as a Composer dependency to load variables from a .env file.

When creating a test.php file in Symfonys Public Folder and querying “echo $_SERVER[‘APP_ENV’]” I’m getting correctly the setted “prod” Variable.

Thanks for your help!

Attached the anonymized vHost File:

<VirtualHost *:80>
    ServerName gate.keeper
    ServerAlias www.gate.keeper

    DocumentRoot /var/www/gk3/public
    <Directory /var/www/gk3/public>
        AllowOverride None
        Order Allow,Deny
        Allow from All

        <IfModule mod_rewrite.c>
            Options -MultiViews
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ index.php [QSA,L]

    # uncomment the following lines if you install assets as symlinks
    # or run into problems when compiling LESS/Sass/CoffeeScript assets
    # <Directory /var/www/gk3>
    #     Options FollowSymlinks
    # </Directory>

    # optionally disable the RewriteEngine for the asset directories
    # which will allow apache to simply reply with a 404 when files are
    # not found instead of passing the request into the full symfony stack
    <Directory /var/www/gk3/public/bundles>
        <IfModule mod_rewrite.c>
            RewriteEngine Off
    ErrorLog /var/log/apache2/gk3_error.log
    CustomLog /var/log/apache2/gk3_access.log combined

    # optionally set the value of the environment variables used in the application
    SetEnv APP_ENV "prod"
    SetEnv APP_SECRET "secret"
    SetEnv DATABASE_URL "mysql://user:password@localhost:3306/db_name"

Java post request with parameters

I saw that lin sends invitation via POST method with specific parameters, in firefox developers tool it looks like:

enter image description here

I usually use Apache HttpClient for send request via JAVA so if parameters are needed just put:

HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(url);
List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
urlParameters.add(new BasicNameValuePair("sn", "C02G8416DRJM"));
post.setEntity(new UrlEncodedFormEntity(urlParameters));
HttpResponse response = client.execute(post);

but I probably do not understand what this ‘tree’ structure means and how to implement it.

Could you suggest me how i can do it?

Url rewriting code in htaccess file [on hold]

This is my orginal link:

and i required that url has to be in this format.
am passing two id (id1/id). am new to htaccess , so doesn’t know anything regarding this if you would help thouroughly. it will be more helpful more for me to work on further projects.

this is my htaccess code. am apearing that url perfectly . but errors am occuring.
RewriteEngine on

#To externally redirect /blog-single?id1=foo&id=bar to /mochBlog/bar
RewriteCond %{QUERY_STRING} ^id1=([^&]+)&id=(.+)$ [NC]
RewriteRule ^.*$ /MCoH-Blog/%1/%2? [R,L]
#To internally redirect /mochBlog/bar to /blog-single?id1=foo&id=bar
RewriteRule ^MCoH-Blog/([^&]+)/(.+)$/blog-single?id1=$1&id=$2 [L]

and this the Error am Occuring

Object not found!
The requested URL was not found on this server. If you entered the URL 
manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.

Error 404
Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.28

i tried it in my localhost

Apache Webserver with DDNS Configuration

After browsing most of the help I could find on this (especially here on StackOverflow), I cannot get my configuration right. nslookup shows my domain pointing to my external IP correctly. Port 80 is forwarded and I have nothing in the Windows firewall blocking apache or node.js. Node.js creates an http server (not https) and listens to port 80. I can access the webserver on the local machine/network (internalIP:80/index.html) without issue.

Using Wampserver 3.1.0 and an account with My No-IP, my httpd-vhosts file:

Listen 80

# Virtual Hosts

<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted
<VirtualHost *:80>
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted

My httpd.conf file:

# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:> for detailed information.
# In particular, see
# <URL:>
# for a discussion of each configuration directive.
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "logs/access_log"
# with ServerRoot set to "/usr/local/apache2" will be interpreted by the
# server as "/usr/local/apache2/logs/access_log", whereas "/logs/access_log"
# will be interpreted as '/logs/access_log'.
# NOTE: Where filenames are specified, you must use forward slashes
# instead of backslashes (e.g., "c:/apache" instead of "c:\apache").
# If a drive letter is omitted, the drive on which httpd.exe is located
# will be used by default.  It is recommended that you always supply
# an explicit drive letter in absolute paths to avoid confusion.
ServerSignature On
ServerTokens Full

# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.

# Apache variable names used by Apache conf files:
# The names and contents of variables:
# should never be changed.
Define APACHE24 Apache2.4
Define VERSION_APACHE 2.4.27
Define INSTALL_DIR c:/wamp64
Define APACHE_DIR ${INSTALL_DIR}/bin/apache/apache${VERSION_APACHE}

ServerRoot "${APACHE_DIR}"

# Mutex: Allows you to set the mutex mechanism and mutex file directory
# for individual mutexes, or change the global defaults
# Uncomment and change the directory if mutexes are file-based and the     default
# mutex file directory is not on a local disk or is not appropriate for some
# other reason.
# Mutex default:logs

# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
Listen [2601:19b:4401:e029::8fad]:80

# Dynamic Shared Object (DSO) Support
# To be able to use the functionality of a module which was built as a DSO     you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
# Example:
# LoadModule foo_module modules/

LoadModule php7_module "${INSTALL_DIR}/bin/php/php7.1.9/php7apache2_4.dll"

<IfModule unixd_module>
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
User daemon
Group daemon


# 'Main' server configuration
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.

# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g.

# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
# If your host doesn't have a registered DNS name, enter its IP address here.
ServerName localhost

# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
<Directory "/">
    Require all granted

# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
HostnameLookups Off

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI     MultiViews
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    # The Options directive is both complicated and important.  Please see
    # for more information.
    Options +Indexes +FollowSymLinks +Multiviews

    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    AllowOverride all

    # Controls who can get stuff from this server.

    #   onlineoffline tag - don't remove
    Require all granted

# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
<IfModule dir_module>
    DirectoryIndex index.html

# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
<Files ".ht*">
    Require all denied

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#ErrorLog "logs/error.log"
ErrorLog "${INSTALL_DIR}/logs/apache_error.log"

From there it remain default onward. If anyone needs more information, please ask.

Can anyone point me to an error? Thanks!

Apache not starting in linux mint

Ok, so, I’m fairly new to Apache: I was trying to create a local website (created the .conf file in sites-available folder, created the folder in var/www/mysite/ etc.) then, I stopped Apache (with systemctl stop apache2.service) but now if I try to restart (systemctl restart apache2.service) it throws this error:

Job for apache2.service failed because the control process exited with >error code. See “systemctl status apache2.service” and “journalctl -xe” for details.

This is the result of journalctl -xe:

Mar 22 16:33:13 user-xxx apache2[10403]:  * Starting Apache httpd web server apach
Mar 22 16:33:13 user-xxx apache2[10403]:  *
Mar 22 16:33:13 user-xxx apache2[10403]:  * The apache2 configtest failed.
Mar 22 16:33:13 user-xxx apache2[10403]: Output of config test was:
Mar 22 16:33:13 user-xxx apache2[10403]: apache2: Syntax error on line 140 of /etc/apache2/apache2.conf:
Mar 22 16:33:13 user-xxx apache2[10403]: Action 'configtest' failed.

And the line 140 in /etc/apache2/apache2.conf:

# Include module configuration:
IncludeOptional mods-enabled/*.load <--This one
IncludeOptional mods-enabled/*.conf

So I tried:

sudo apt-get install libapache2-mod-php

And I get:

libapache2-mod-php is already the newest version (

What else I tried: removing Apache and installing again, installing lamp (sudo apt-get install lamp-server^).
I already removed: mysite.conf from available.sites …

Nothing seems to make it work, I keep getting “Job for apache2.service failed”.

How to check if the main domain matches a certain domain and then redirect the request in .htaccess?

What I want to accomplish is that when the user tries to visit the site with url like the following :

so it should redirect to :

With the whole URI and then if user visits the following url as the following : OR

so it should redirect to :

I have tried with the following code but it redirects all requests to as :

# Avoid use of HTTPS for TEST SERVER
RewriteCond %{HTTPS_HOST} ^ [NC,OR]
RewriteRule ^(.*)$$1 [L,R=301,NC]

# Redirect all www or non www to https
RewriteCond %{HTTPS}::%{HTTP_HOST} ^off::(?:www\.)?(.+)$
RewriteRule ^ https://www.%1%{REQUEST_URI} [NE,L,R]

NOTE : I want to redirect with the whole URI not just to the main domain links.

MySQL Module Does Not Start On Xampp

I just installed XAMPP on Windows 10 and tried to run it. The Apache module runs successfully on 443, 1372 port but the MySQL module does not start, and here is the report for that:

    Error: MySQL shutdown unexpectedly.
11:57:44 PM  [mysql]    This may be due to a blocked port, missing dependencies, 
11:57:44 PM  [mysql]    improper privileges, a crash, or a shutdown by another method.
11:57:44 PM  [mysql]    Press the Logs button to view error logs and check
11:57:44 PM  [mysql]    the Windows Event Viewer for more clues
11:57:44 PM  [mysql]    If you need more help, copy and post this
11:57:44 PM  [mysql]    entire log window on the forums

I have searched for some similar problems and they say I have to change the port of MySQL module also. So I changed the port in php.ini from 3306 to 3307.

But again this module can not be run and sometimes it STUCKS at Attempting to start MySQL app... somehow.

So what is your solution to this ?

What is the “system default” http timeout?

I try to find out the timeout of the Apache HttpClient. The doc file* says that the default timeout for http connections is the “system default” timeout. But what is the “system default”? And how can I find out what the value for the “system default” timeout is set to?

*”A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined (system default).

Default: -1″(

How to include/link css (and html) from sub directories?

I’ve set up a very simple web page with some css files and a few html include files that were given to me by someone else.

The directory tree on my server looks like this:

<br /> css/<br /> global.css<br /> site.css<br /> includes/<br /> header.html<br /> footer.html<br /> nav.html<br /> index.html<br /> subdir/<br /> index.html<br />

All of my html files (except the ones in the includes directory) have this kind of stuff in it (among other things)

<br /> ...<br /> <link href="css/global.css" rel="stylesheet" /><br /> <link href="css/site.css" rel="stylesheet" /><br /> <body><br /> <!--#include file="includes/header.html" /><br /> ...<br /> </body><br /> ...<br />

This setup works fine with the top level index.html page that I have, but fails with anything else (i.e., subdir/index.html). I get a message in the browser that says:

[an error occurred while processing this directive]

I know that the apache web server just can’t find the css and include files (I’ve checked the logs), but I don’t know where to tell it to look for them. I’ve tried something like this:

<link href="../css/global.css" rel="stylesheet" />

but it doesn’t work either.

I am really new at web programming so I apologize if this is overly basic stuff.