| Author | 
  | 
Onetoomanysodas
 
 
  Joined: 05 Jun 2006 Posts: 4 Location: Everywhere but nowhere
  | 
 Posted: Mon 05 Jun '06 1:27    Post subject: Editing the autoindex | 
     | 
 
  | 
 
| In the httpd.conf configuration file, how could I get Apache to direct the user to a specific file instead of autoindexing. The file would be a php autoindex file with the folder in the url argument. Thank you. | 
 
  | 
| Back to top | 
 | 
James Blond Moderator
  
  Joined: 19 Jan 2006 Posts: 7443 Location: EU, Germany, Next to Hamburg
  | 
 | 
| Back to top | 
 | 
Onetoomanysodas
 
 
  Joined: 05 Jun 2006 Posts: 4 Location: Everywhere but nowhere
  | 
 Posted: Wed 07 Jun '06 1:51    Post subject:  | 
     | 
 
  | 
 
Thank you, I was aware of calling the script in the arguments for the DirectoryIndex line. I am still somewhat confused how I can do this.
 
 
There is one file, let's say "/MyIndex.php" (under the base directory), that I want Apache to redirect to in case of a folder without and index file is requested or if the requested file/directory does not exist.
 
 
MyIndex.php accepts one argument in the GET variable so I'm hoping to sent it the requested directory to a variable "request". If we pretend that "$R" is the requested directory as a string, then to show you what I'm hoping to accomplish in Apache demonstrated with PHP: the redirect would look like this:
 
 
 	  | Code: | 	 		  | "MyIndex.php?request=" . $R; | 	  
 
 
Obviously I want to redirect any requested folder that does not exist so I could use the ErrorDocument 404 "/MyIndex.php", but I do not know the syntax nor the correct variable to add to that the requested direcotry. 
 
The other problem still frustrates me because I am clueless how to redirect to such a file instead of autoindexing. I also do not know how I could implement the Apache code I found relevant on the suggested page:
 
 	  | Code: | 	 		  RewriteEngine on
 
RewriteCond   %{REQUEST_URI} !-U
 
RewriteRule   ^(.+)          /MyIndex.php?request=$1 | 	  
 
 
Thank you for reading. | 
 
  | 
| Back to top | 
 | 
Onetoomanysodas
 
 
  Joined: 05 Jun 2006 Posts: 4 Location: Everywhere but nowhere
  | 
 Posted: Sat 10 Jun '06 5:53    Post subject:  | 
     | 
 
  | 
 
| Yes I know this is a double-post bump but I would really appreciate it if someone took the time to read and reply please. Thank you. | 
 
  | 
| Back to top | 
 | 
James Blond Moderator
  
  Joined: 19 Jan 2006 Posts: 7443 Location: EU, Germany, Next to Hamburg
  | 
 Posted: Sat 10 Jun '06 10:26    Post subject:  | 
     | 
 
  | 
 
http.conf
 
 	  | Code: | 	 		  
 
ErrorDocument 404 "C:/apache2/htdocs/MyIndex.php" 
 
 | 	  
 
 
or 
 
 
[code]
 
DocumentRoot "/server2/www"
 
<Directory "/server2/www">
 
    Options Indexes FollowSymLinks
 
    AllowOverride None
 
    Order allow,deny
 
    Allow from all
 
 
RewriteEngine on 
 
RewriteCond   %{REQUEST_URI} !-U 
 
RewriteRule   ^(.+)          /MyIndex.php?request=$1
 
 
</Directory> | 
 
  | 
| Back to top | 
 |