What is this net::ERR_NAME_NOT_RESOLVED error in php?

Asked

Viewed 6,265 times

0

Hello, I am trying to pass parameters to a php file, email and password, for login use by the following url:"http://www.vigilantescomunitarios.com/php/[email protected]&sen=12345" and the following warning appears

net:ERR_NAME_NOT_RESOLVED

Would the parameters be in trouble? Because when I run the url at hand "http://vigilantescomunitarios.com/php/login.php" wheel and of course, warns that the two variables are undefined

Notice: Undefined index: Ema in /var/www/vigilantescomunitarios.com/public_html/www/php/login.php on line 17

Notice: Undefined index: sen in /var/www/vigilantescomunitarios.com/public_html/www/php/login.php on line 18

Controller:

var ema = usuario.email;
var sen = usuario.senha;
$http.post("http://www.vigilantescomunitarios.com/php/login.php?ema="+ema+"&sen="+sen).success(function (response){
        console.log(response);
}

PHP:

<?php
ini_set('display_errors', true);
error_reporting(E_ALL);

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type,x-prototype-version,x-  requested-with');

include_once("conPDO.php");

$pdo = conectar();

$email = $_GET['ema'];
$senha = $_GET['sen'];
echo $email.' - '.$senha;
?>
  • 1

    The problem is in www., there is no such subdomain, so you cannot find the address. If you access http://vigilantescomunitarios.com/php/[email protected]&sen=12345 (note: without the www.!) it will carry normally.

1 answer

2


The problem is that the site does not have the subdomain www.. For this reason error of not finding the domain is shown, because it does not exist. Removing the www. URL will not exist error. ;)

Solution:

Method 1 via Javascript:

$http.post("http://vigilantescomunitarios.com/php/login.php?ema="+ema+"&sen="+sen).success(function (response){
        console.log(response);
}

Simply remove the www..

But that doesn’t solve the whole problem!

Method 2 via Apache:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

This will redirect the http://www... to the http://...

Method 2 via Nginx:

server {
    server_name www.vigilantescomunitarios.com;
    return 301 $scheme://vigilantescomunitarios.com$request_uri;
}

This will redirect the http://www... to the http://... or https://www... for https://....

To perform Method 2 you need to configure the DNS, thus pointing the subdomain and the domain to the same server.

For example:

DigitalOcean

Image and some information were extracted of this tutorial from Digitalocean. Configuration panel will vary from DNS to DNS.

  • Because it’s @Inkeliz, it’s just that I’m using the Digitalocean service and they passed me the step-by-step to install and configure everything. Then I pass you as is apache2.conf.

  • See: <Virtualhost *:80> Serveradmin [email protected] Servername vigilantescomunitarios.com Serveralias www.vigilantescomunitarios.com Documentroot /var/www/vigilantescomunitarios.com/public_html/www Errorlog ${APACHE_LOG_DIR}/error.log Customlog ${APACHE_LOG_DIR}/access.log Combined </Virtualhost>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.