Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
$ ls
Layouts    Pictures  index.html
$ cat .htaccess
RewriteEngine On

#REDIRECT pages that are not specifically redirected
RewriteCond %{HTTP_HOST} !^www\.mySite\.com$ [NC] 
RewriteRule ^(.*)$$1 [R=301,L] 

# Some redirections here

ErrorDocument 404
DirectoryIndex index.html wrongWay.html Layouts/wrongWay.html

IndexIgnore *
Options -Indexes
$ ls Pictures

If user access Pictures/A/ -directory-listing, I want that the user will see the wrongWay.html or Layouts/wrongWay.html because the dir Pictures/A does not cotain index.html. My zeroth idea was the not-working .htaccess above. Then, my first idea was $ find . -type d -exec cp .htaccess '{}' \; but then I also need $ find . -type d -exec cp Layouts/wrongWay.html '{}' \; and $ find . -type d -exec cp Pictures/wrongWay.png '{}' \; -- and besides that I need to fix some paths/etc-dummy, reuse to the dogs. Now I want some simple way to accomplish this. Look I have working .htaccess for one directory in the root level but now I need just a command to make it apply all subdirectories, which cmd and how?

share|improve this question
Could you include that .htaccess file in question? – kupson Mar 3 '12 at 9:26
@kupson: added. – user112744 Mar 3 '12 at 16:39
up vote 1 down vote accepted

You need to provide a correct local URL.

As defined in your .htaccess file apache would look for Pictures/A/index.html then Pictures/A/wrongWay.html then Pictures/A/Layouts/wrongWay.html.

Your fix is to provide a suitable local URL so that apache can find it e.g. if your Layouts directory is at then

DirectoryIndex index.html wrongWay.html /Layouts/wrongWay.html

would work as you expect.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.