if my url is

n i have an inner directory

how do i check the url is right or not n lead it to an error page

Dani AI

Generated

The core issue is DNS, not the page files: a browser shows "server not found" when the subdomain name does not resolve to any IP, so the site never receives a request it could redirect. 's example (typing a non-existent subdomain) requires that the host name first resolve to your server; after that the server can serve or redirect to your custom error page.

Practical steps (in order):

  1. Add a wildcard DNS A record for *.yourdomain.com pointing to your web server IP (many DNS panels call this a wildcard or use * as the name).
  2. Configure the web server to catch any Host header and route unknown subdomains to the custom page. Example Apache vhost (replace example.com and paths):
<VirtualHost *:80>
    ServerName example.com
    ServerAlias *.example.com
    DocumentRoot /var/www/example
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
    RewriteRule ^/?(.*)$ /errorpages/bad-subdomain.html [L,R=302]
</VirtualHost>

An equivalent minimal Nginx block:

server {
    listen 80;
    server_name .example.com;
    root /var/www/example;
    if ($host != 'example.com') { return 302 /errorpages/bad-subdomain.html; }
}

Quick tests from the command line (use your domain/server IP):

dig mal.example.com
curl -I -H "Host: mal.example.com" http://<server-ip>/

Notes and caveats: if you only control files (index.html) but not DNS or vhost settings, the browser will still show "server not found" — this is the gap between , and 's suggestions. On shared hosting you may need the provider to add the wildcard DNS or a “parked/wildcard subdomain.” For HTTPS, a wildcard TLS certificate (*.example.com) or a SAN cert is required, otherwise visitors will see certificate errors even if the redirect works.

Recommended Answers

All 12 Replies

you mean like

$_SERVER['SERVER_ADDR']; //or
$_SERVER['DOCUMENT_ROOT'];

?

I believe you are trying to create a sub directory on your domain?

So for example.....if your domain was www.me.com and you wanted to create a sub directory as ....

First you need to create the sub directory on your domain as you then point your browser to or

You will of course need a document in the sub directory such as an index.htm or something. Hope this helps and if not then feel free to get in touch.


Justin

if my url is

n i have an inner directory

how do i check the url is right or not n lead it to an error page

see its li this
i have www.me.com
n created
incase if i give it shud not say server not found instead lead me to my home pages error page.. sayin url typed is wrong!

Member Avatar for Member #244294

sub domains generally replace the 'www' default, as the www is the primary domain pointer, most domain names can be reached without adding the www prefix for example http://x.com and this will point directly to the same location adding the www.

would be the correct use of the sub domain with the main site appearing on http://www.x.com and any other sub's http//here.x.com

unless you have named you sub 'www.a' which i would not recommend as you can get some very odd results from domain control panels adding extra '.'s, then your sub would be .

if you want the www use a hyphen or an underscore to make it better accepted by the world wide dns www-a or www_a. so you would use and

Also remember it can take 24 - 48 hours for any new sub domain to be populated across the world dns records to be accessible from anywhere in the world.

hope that helps.

no no!!! u guys not gettin the right stuff!!!

Member Avatar for Member #244294

no no!!! u guys not gettin the right stuff!!!

Could you please explain with as much detail as possible so we can help you, otherwise we are shooting fish in the ocean. :)

Hmm have you uploaded a file or 'webpage' to your sub domain folder?

If you have no file to direct to then you will only get to your server as their is nothing their for it to show!

My advice is to upload a notepad document named index.html to the folder on your server that is the subdomain! Type some html in the document such as <html>hello</html>

Once this is done you should be able to type in www.me.com/you.index.html then it will work but you should just see the hello on a plain white screen.

Sorry if we are not getting it right but we are trying so please explain in more detail

Justin

Member Avatar for Member #244294

do you mean your sub domains are looping back to the same location as the main site?

if so you need to change the root folder the sub domain points too

on my domain i have 3 sub domains, each points to a different root folder path on the host machine like this:

/home/www/x.
/home/www/1.x.
/home/www/2.x.
/home/www/beta.x.

each folder after the /www/ is a new root folder for that sub, and although each sub operates on the same ip as the main domain the host routes the traffic to each sub correctly.

so for each:

http://x.

Would show a different site, or would error 404 resource not found for a site root that contains nothing / doesn't exist.

i think whats happening with yours is that the sub you have created is pointing to the same location on the server as your main domain, and its looping back on itself thus creating the problem you are getting.

HMMM k its li this
Try
instead of
then it says server not found but i want it to take me to a error page of yahoo.com n say the url typed is wrong.... i already have an eroor page which is linked if my url is wrong after .com but between it does lead me to an error page

use htaccess file to redirect the error page

Member Avatar for Member #244294

Unique Error 404 Pages are something you need to talk to your hosting provider about, IF they allow you to create your own then it should be a simple case of having the custom page in the root of your domain. Depending how their services are set up, you may or may not be able to do this.

Oh,

Are you asking how to set custom error pages?


Well, .htaccess or by using the control panel. Look in you CP for custom page or custom error pages.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.