Seite 1 von 1

[ENG] Redirect via HTACCESS only files

Verfasst: 26.12.2011 19:50
von magonicola
Sorry for english, I cannot read and write deutch.
I've got a website ( http://unina.stidue.net ) managed by a simply directory listing by apache "fancyed" with header, footer and css.
I want that ALL and ONLY files (not dirs) must be served by PHP script who can do a CAPTCHA test before stream the file.
I think I can acheive this using a rule in my .htaccess file that makes these transformations:

Code: Alles auswählen

http://unina.stidue.net/ -> http://unina.stidue.net/ (No changes)

http://www.unina.stidue.net/folder1/ -> http://www.unina.stidue.net/folder1/ (No changes)

http://unina.stidue.net/fold1/fold2/ -> http://unina.stidue.net/fold1/fold2/ (No changes)

http://unina.stidue.net/folder1/file1.ext -> http://unina.stidue.net/include/fmanager.php?file=/folder1/file1.ext

http://www.unina.stidue.net/fold1/fold2/file2.ess -> http://www.unina.stidue.net/include/fmanager.php?file=/fold1/fold2/file2.ess
For now, my htaccess is like:

Code: Alles auswählen

RewriteEngine On

Options Indexes FollowSymLinks
IndexOptions Charset=UTF-8
IndexOptions +FancyIndexing
IndexOptions +VersionSort
IndexOptions +HTMLTable
IndexOptions +FoldersFirst
IndexOptions +IconsAreLinks
IndexOptions +IgnoreCase
IndexOptions +SuppressDescription
IndexOptions +SuppressHTMLPreamble
IndexOptions +XHTML
IndexOptions +IconWidth=16
IndexOptions +IconHeight=16
IndexOptions +NameWidth=55
IndexOrderDefault Ascending Name
HeaderName /include/header.html
ReadmeName /include/footer.html

IndexIgnore /include
IndexIgnore */.htaccess
IndexIgnore /COPYING
IndexIgnore /README.md
IndexIgnore /vhost.conf
IndexIgnore /favicon.gif
IndexIgnore /favicon.ico
IndexIgnore /img
IndexIgnore /contribuisci
IndexIgnore /google898fc143c2921769.html
IndexIgnore /robots.txt
IndexIgnore /sitemap.xml
IndexIgnore /sitemap.xsl
IndexIgnore /y_key_70f072abda42ab66.html
IndexIgnore /e72
IndexIgnore /c7
IndexIgnore /wf
IndexIgnore SSS*

AddIcon /include/icons2/type_application.png .exe .app .EXE .APP
AddIcon /include/icons2/type_binary.png .bin .hqx .uu .BIN .HQX .UU
AddIcon /include/icons2/type_box.png .tar .tgz .tbz .tbz2 bundle .rar .TAR .TGZ .TBZ .TBZ2
AddIcon /include/icons2/type_rar.png .rar .RAR
AddIcon /include/icons2/type_html.png .htm .html .HTM .HTML
AddIcon /include/icons2/type_code.png .htx .htmls .dhtml .phtml .shtml .inc .ssi .c .cc .css .h .rb .js .rb .pl .py .sh .shar .csh .ksh .tcl .as
AddIcon /include/icons2/type_database.png .db .sqlite
AddIcon /include/icons2/type_disc.png .iso .image
AddIcon /include/icons2/type_document.png .ttf
AddIcon /include/icons2/type_excel.png .xlsx .xls .xlm .xlt .xla .xlb .xld .xlk .xll .xlv .xlw
AddIcon /include/icons2/type_flash.png .flv
AddIcon /include/icons2/type_illustrator.png .ai .eps .epsf .epsi
AddIcon /include/icons2/type_pdf.png .pdf .PDF
AddIcon /include/icons2/type_php.png .php .phps .php5 .php3 .php4 .phtm
AddIcon /include/icons2/type_photoshop.png .psd
AddIcon /include/icons2/type_monitor.png .ps
AddIcon /include/icons2/type_powerpoint.png .ppt .pptx .ppz .pot .pwz .ppa .pps .pow
AddIcon /include/icons2/type_swf.png .swf
AddIcon /include/icons2/type_text.png .tex .dvi
AddIcon /include/icons2/type_vcf.png .vcf .vcard
AddIcon /include/icons2/type_word.png .doc .docx
AddIcon /include/icons2/type_zip.png .Z .z .tgz .gz .zip
AddIcon /include/icons2/type_globe.png .wrl .wrl.gz .vrm .vrml .iv
AddIcon /include/icons2/type_android.gif .apk .APK

AddIconByType (TXT,/include/icons2/type_text.png) text/*
AddIconByType (IMG,/include/icons2/type_image.png) image/*
AddIconByType (SND,/include/icons2/type_audio.png) audio/*
AddIconByType (VID,/include/icons2/type_video.png) video/*
AddIconByEncoding (CMP,/include/icons2/type_box.png) x-compress x-gzip

AddIcon /include/icons2/back.png ..
AddIcon /include/icons2/information.png README INSTALL
AddIcon /include/icons2/type_folder.png ^^DIRECTORY^^
AddIcon /include/icons2/blank.png ^^BLANKICON^^

DefaultIcon /include/icons2/type_document.png

order allow,deny
allow from all

ErrorDocument 400 /include/400.html
ErrorDocument 401 /include/400.html
ErrorDocument 403 /include/403.html
ErrorDocument 404 /include/400.html

RewriteRule ^(.+)/(.+).(.+)$ include/fmanager.php [L]
But doesen't work (I can't manage only files and I'm not able to set /include/ and utility files (i.e. files in root, hidden via indexIgnore) "transparent" to this htaccess.
Can you help me?
Thank you so much.