Forum Moderators: phranque

Message Too Old, No Replies

help showing directories contents using htaccess

         

jbcobbs

12:11 am on Mar 8, 2010 (gmt 0)

10+ Year Member



The site I just built for a client uses a url structure of www.sampleurl.com/index.php?page - I have code in the htaccess that removes the index.php? which works fine. My problem is my client has folders on the site that previously he used for file hosting/non website purposes that should show a list of files in that directory. Since the website launch i just get a screen saying "Apache/2.2.14 (CentOS) mod_ssl/2.2.14 0.9.8l DAV/2 mod_auth_passthrough/2.1 FrontPage/5.0.2.2635 Server at example.com Port 80" - I read an article that adding this type of code RewriteCond %{REQUEST_URI} "/private/" RewriteRule (.*) $1 [L] would make this available and tell the system to apply any htaccess rules to it. I dont know too much about this stuff so any help would be appreciated.


# -- LG .htaccess Generator Start --
# .htaccess generated by LG .htaccess Generator v1.0.0
# <snip>
# addon domain exceptions
RewriteCond %{HTTP_HOST} ^(www\.)?sampleurl\.com
RewriteRule .* - [L]

# Fix queries for actions, urls and css in EE
RewriteCond %{QUERY_STRING} ^(ACT=.*)$ [NC,OR]
RewriteCond %{QUERY_STRING} ^(URL=.*)$ [NC,OR]
RewriteCond %{QUERY_STRING} ^(CSS=.*)$ [NC]
RewriteRule ^(.*)$ /index.php\?&%{QUERY_STRING} [L]


# secure .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>

# Dont list files in index pages
IndexIgnore *

# EE 404 page for missing pages
ErrorDocument 404 /index.php?/

# Simple 404 for missing files
<FilesMatch "(\.jpe?g|gif|png|bmp)$">
ErrorDocument 404 "File Not Found"
</FilesMatch>

RewriteEngine On
RewriteCond %{REQUEST_URI} "/private/" [or]
RewriteCond %{REQUEST_URI} "/SI/"
RewriteRule (.*) $1 [L]
RewriteBase /

# remove the www
RewriteCond %{HTTP_HOST} ^(www\.$) [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^blog/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/?$ blog/$4/ [R=301,L]

# Add a trailing slash to paths without an extension
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule ^(.*)$ $1/ [L,R=301]

# Remove index.php
# Uses the "include method"
# http://expressionengine.com/wiki/Remove_index.php_From_URLs/#Include_List_Method
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5})$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/(site|search|Entertainment|Index|About|Activities|Recipes|Contact|Sponsors|embeds|sponsors_gallery|galleries|Location|Blog||members|P[0-9]{2,8}) [NC]
RewriteRule ^(.*)$ /index.php?/$1 [L]

# Remove IE image toolbar
<FilesMatch "\.(html|htm|php)$">
Header set imagetoolbar "no"
</FilesMatch>
# -- LG .htaccess Generator End --

[edited by: jdMorgan at 6:58 am (utc) on Mar 10, 2010]
[edit reason] Removed promotional link and private domain citation. [/edit]

jdMorgan

7:19 pm on Mar 14, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In general, you will need to exclude the "special" URL-paths from all other rules which they might match, either by adding RewriteConds with negative-pattern matches to those rules so the those rules are not invoked if the requested URL-path is one of the "special" ones, or by adding a "skip rule" before all of those other rules, so that the following rules are skipped (See the RewriteRule [S] flag in the Apache mod_rewrite documentation).

Jim

cinemaduro

8:45 pm on May 17, 2010 (gmt 0)

10+ Year Member



I think you could also just add an .htaccess file into the individual subfolders that turns mod_rewrite off.

All it needs to be is a file with:

RewriteEngine off