Lightninghawk 40 Posting Whiz in Training

Ok so you are having the same problem I am. You wanted to hide your directory listing because you were worried about someone seeing it and being able to manipulate it.

Or your index directory wasn't Index.html, it was something like Index.php, and you thought it just looked sloppy having your directory listing show up. (some what embarrassing to because you know everybody that tries to view it has to find the right index file or something like that).

Everybody has been telling you to use a .htaccess file right? Yeah, I thought so. I was told that to, but I couldn't ever get the dern things to work. So I went looking for an alternate method. Did a little HTML looking up and talked with a friend (ЯŶŋĚ™) and we did some digging.

We finally came up with this very, very simple HTML code that you can edit and modify anyway that you want to, but here is how I am using it currently. I plan to use a Picture or Flash Animation for Directories that people should not be attempting to enter, but that will be later on.

<html>
<head>
<title>The 411~Exchange </title>
<meta http-equiv="refresh" content="4; url=http://www.daniweb.com">
</head>
<body bgcolor="#000000">
<br>
<br>
<br>
<br>
<br>
&nbsp;<p><b>
<a href="http://www.daniweb.com"><center><h1>You Are Entering DaniWeb</h1></a></b></p>
</p></center>
</color>
</body>
</html>

Like I mentioned. This code is just a simple and flexable one. Nothing complicated, and it doesn't have to be exactly like this. You don't need anything more than.

<HTML>
<Head>
<meta http-equiv="refresh" content="4; url=http://www.daniweb.com">
</HEAD>
</HTML>

Here is a site that you can view. Everything Redirects back here, and there is nothing else on the site. So it is not an add. It was created for the sole purpose to show how this works. Due to the domain . though the site name will stay in the address bar when it redirects to daniweb. I turned url cloaking off, but it persists. Lame service :P


If you have questions. I will be happy to answer as best that I can :)


ahh a couple things first

<meta http-equiv="refresh" content="4; url=http://www.daniweb.com">

content="4 <- this number is the amount of seconds the page shows, and 0 is a allowed.

Dani AI

Generated

As demonstrated, a client-side refresh is a quick, user-facing way to send visitors elsewhere, but it’s only a presentation-layer trick. It does not stop the server from exposing files, it can leave the original URL visible (host cloaking), and it’s poor for SEO and automation. For a durable, correct solution use server-side settings so Apache answers with the right status and content.

Common, effective .htaccess options (place in the directory root):

# disable directory listings
Options -Indexes

# prefer index.php over index.html
DirectoryIndex index.php index.html

# return a custom 403 page instead of a listing
ErrorDocument 403 /403.html

If you actually need a redirect that changes the browser URL, use a server redirect (Redirect or mod_rewrite) rather than a client meta refresh. A proper 301/302 from the server is what search engines and other clients expect.

Troubleshooting why .htaccess “doesn’t work”: check the filename is exactly .htaccess, ensure permissions are reasonable (e.g. 644), confirm your host allows overrides (Apache’s AllowOverride must permit it), and verify required modules (mod_rewrite) are enabled. From a shell or local machine, inspect responses with a header-only request (for example: curl -I http://example.com/somepath/) to see status codes and headers — that shows whether redirects are coming from the server or the client.

Security note: turning off listings only hides directory indexes. Do not rely on redirects to protect sensitive files — move them outside the web root, tighten filesystem permissions, or use proper authentication (Basic auth or application-level checks) for real protection.

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.