logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Editing the autoindex
Author
Onetoomanysodas



Joined: 05 Jun 2006
Posts: 4
Location: Everywhere but nowhere

PostPosted: Mon 05 Jun '06 1:27    Post subject: Editing the autoindex Reply with quote

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: 7371
Location: Germany, Next to Hamburg

PostPosted: Mon 05 Jun '06 8:39    Post subject: Reply with quote

At first you need to set that your script is called.
DirectoryIndex YourIndex.php index.php index.htm index.html
Secondly you need to use mod_rewrite please see http://httpd.apache.org/docs/2.2/misc/rewriteguide.html for that.
Back to top
Onetoomanysodas



Joined: 05 Jun 2006
Posts: 4
Location: Everywhere but nowhere

PostPosted: Wed 07 Jun '06 1:51    Post subject: Reply with quote

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

PostPosted: Sat 10 Jun '06 5:53    Post subject: Reply with quote

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: 7371
Location: Germany, Next to Hamburg

PostPosted: Sat 10 Jun '06 10:26    Post subject: Reply with quote

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


Reply to topic   Topic: Editing the autoindex View previous topic :: View next topic
Post new topic   Forum Index -> Apache