473,399 Members | 4,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Give a false 404 Directory not found via .htaccess

dlite922
1,584 Expert 1GB
I have a framework where I usually have a /pub and /app folder and only give apache /pub. But unfortunately with a setup I have, my files are in the same directory as /app.

I know how to distable directory listing and peeking around (give access denied message), but I want to completely mask it. For instance...

With that first solution someone can guess that /app exists because he gets an access denied and that /foo doesn't exist because you get a "Not Found" message.

How can I fake the Not Found error?

....besides pasting Apache's html of that page in a index.html file, other than the fact that this is really messy (lots of sub directories) I'm looking for a cleaner solution.
Jan 11 '10 #1
2 5006
Dormilich
8,658 Expert Mod 8TB
you could always serve a "not found" or "access denied" page for non-public folders using mod_rewrite …
Jan 12 '10 #2
dgreenhouse
250 Expert 100+
You could redirect any public access to that directory to a "not found" error via the .htaccess file using a rewrite condition and rule. That way, only the internal scripts have access the your /app directory, but as desired, web visitors won't see it.

Assuming you have an error document 404.php in your root, this might help:
(In the .htaccess file)

RewriteRule ^app/* /404.php
Jan 23 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: JW | last post by:
I have a directory protected with .htaccess / .htpasswd. After I'm validated, I run a php script which bombs out when trying to write a file to that directory. If I chmod 777 on the directory...
4
by: Erik Andersson | last post by:
Hi! I need to translate the path /category_name/sub_category_name/ to /category.php?sub_category_id=2
2
by: bonehead | last post by:
Many thanks to all who replied to my previous post regaring proper installation of phpMyAdmin on unix/apache. Okay, I thought I had correctly followed all the steps to password-secure the...
5
by: J C-W | last post by:
I have a directory with files (of various formats) contained within a website which uses PHP to control user access via session variables. I would like to protect the directory from direct external...
0
by: FleaBite | last post by:
Hi, I have developed a web service in PHP using NuSOAP. I want some form of security for this WS, so I've put it in a directory which is password protected, using an htaccess file. The...
8
by: gil | last post by:
Is it possible to prevent a browser from listing the entire contents of a folder? The site, is hosted on my ISP with the following layout- site/ "user name from ISP" pagefile (dir)...
5
by: deko | last post by:
I'm trying to redirect requests for /index.php to /mydirectory/index.php If I use an index file in / with only this line: <?php header("Location:http://www.mysite.com/mydirectory/"); ?> that...
3
by: Tobias Wendorff | last post by:
Hi there, I've programmed an access-control via header()-function. It checks an username and password in database ... nothing special. Currently, the control gives access to a download, but I...
13
by: Lars Willich | last post by:
As far as I know I can override the php settings for a certain branch of the whole directory tree by putting a additional, new php.ini in this directory. Is this true ? If I assign in this new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.