Rouji / single_php_filehost

Simple Filehosting Page in a Single PHP File (obvious 0x0 clone)
ISC License
235 stars 35 forks source link

How can I configure the .htaccess for Webspace #4

Closed Askadelion closed 3 years ago

Askadelion commented 3 years ago

When i use this, come an error:

<Directory /path/to/webroot/>
    Options +FollowSymLinks -MultiViews -Indexes
    AddDefaultCharset UTF-8
    AllowOverride None

    RewriteEngine On
    RewriteCond "%{ENV:REDIRECT_STATUS}" "^$"
    RewriteRule "^/?$" "index.php" [L,END]
    RewriteRule "^(.+)$" "files/$1" [L,END]
</Directory>
<Directory /path/to/webroot/files>
    Options -ExecCGI
    php_flag engine off
    SetHandler None
    AddType text/plain .php .php5 .html .htm .cpp .c .h .sh
</Directory>

I think is only for Apache Root Config or? How i Configure this for mod_rewrite, for a webspace Package? Can everyone help me?

Rouji commented 3 years ago

The example config is already mostly rewrite... What exactly are you having problems with?

Askadelion commented 3 years ago

i can only insert the htaccess in the folder from index root, i can not modify direkt the apache

files
.htaccess
index.php

when i make insert this come error:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at service@webmailer.de to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

i have try modify so:

<IfModule mod_rewrite.c>
    Options +FollowSymLinks -MultiViews -Indexes
    AddDefaultCharset UTF-8
    AllowOverride None

    RewriteEngine On
    RewriteCond "%{ENV:REDIRECT_STATUS}" "^$"
    RewriteRule "^/?$" "index.php" [L,END]
    RewriteRule "^(.+)$" "files/$1" [L,END]
</IfModule>

but the same problem

Rouji commented 3 years ago

AllowOverride isn't allowed in .htaccess, I think.
Also don't forget about the 'files' dir's config, or prepare to get pwned.

Askadelion commented 3 years ago

i have now use this;

RewriteEngine On
RewriteRule "^/?$" "index.php" [L,END]
RewriteRule "^(.+)$" "files/$1" [L,END]

AddCharset UTF-8 .txt

Now running ur script

Rouji commented 3 years ago

👍

...you did configure the 'files' dir properly, right?

Askadelion commented 3 years ago

i don know if correct but the .htacces is not in the Files dir xDD, but ist run ^^" i have only a one .htaccess in the root with follow lines

RewriteEngine On
RewriteRule "^/?$" "index.php" [L,END]
RewriteRule "^(.+)$" "files/$1" [L,END]

AddCharset UTF-8 .txt
Rouji commented 3 years ago

That won't prevent people from uploading a .php file and abusing your server.

Askadelion commented 3 years ago

ahh i know what u mean, what i musst be change for it i have now a, second htaccess created an in the files dir with follow lines

AddType text/plain .php
AddType text/plain .php5
AddType text/plain .html
AddType text/plain .htm
RemoveHandler .php
RemoveHandler .php5
RemoveHandler .html
RemoveHandler .htm
Rouji commented 3 years ago

See example in README.

Please be aware that this thing is very easy to abuse if you don't know what you're doing. (Also it seems like you're using some shared webhost, which probably won't be happy with you hosting this either)

Askadelion commented 3 years ago

i know, i have the ok from webhoster when i will use this ^^ but the spport from hoster for help is bad xD not really help

Rouji commented 3 years ago

That doesn't sound very reassuring.
I wish you the best of luck anyway.