1

I am a nubby to programming. I want to create an advertising captive portal for my shop. I need it to display a website hosted on a miniweb. location http: //192.168.0.200:8000/pombem.html I need all users connected to be automatically redirected on the local page but it appears I am not registering any progress. I request for help. I am using ESP8266

----------

#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>

const byte DNS_PORT = 53;
IPAddress apIP(192, 168, 0, 110);
DNSServer dnsServer;
ESP8266WebServer webServer(80);

String responseHTML = ""
                      "<!DOCTYPE html><html lang='en'><head>"
                      "<meta name='viewport' content='width=device-width'>"
                      "<title>Magufuli</title></head><body>"
                      "<h1>WELCOME TO THE GAMING PORTAL</h1><p>YOUR ULTIMATE DESTINATION."
                      " YOU ARE CURRENTLY CONNECTED TO THE PORTAL TO THE UNCHALLENGED GAMERS DESTINATION.</p><h1>THE ULTIMATE GUIDE</h1><p>Click on the link below to access the different services ASAP</p><p>Contact us for support on 0787429007 or 0751726782</p><p>[url]http://192.168.0.200:8000/pombem.html][/url]</p><p>Check out the latest software [url]http://192.168.0.200:8000/pombem.html][/url]for:</p><ol><li>PS3</li><li>PC</li><li>PS2</li><li>Mobile phones</li><li>XBOX 360</li></ol><p>Get yourself or gift a friend, relative with the century's ultimate consoles</p><ol><li>PS3 at 500,000 Ush</li><li>XBOX 360 at only 450,000 Ush</li><li>Handheld Consoles</li><li>Game controllers, pads for PS4, PS3, PS2 and XBOX etc</li></ol><p>&nbsp;</p></body></html>";
//I need to display the file pombe.html//
void setup() {
  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
  WiFi.softAP("JOHN POMBE"); //hotspot name

  // if DNSServer is started with "*" for domain name, it will reply with
  // provided IP to all DNS request
  dnsServer.start(DNS_PORT, "*", apIP);

  // replay to all requests with same HTML
  webServer.onNotFound([]() {
    webServer.send(200, "text/html", responseHTML);
  });
  webServer.begin();
}

void loop() {
  dnsServer.processNextRequest();
  webServer.handleClient();
}
  • Assuming the code above successfully returns a HTML page, regardless of what domain/page was requested (with HTTPS errors?), I think you're looking for something like this: https://stackoverflow.com/questions/5411538/redirect-from-an-html-page – Adam Smooch Nov 03 '21 at 13:37

0 Answers0