Here is from settings.py. I can upload files, browse the file names.
# Main Media Settings
MEDIA_ROOT = getattr(settings, "FILEBROWSER_MEDIA_ROOT", 'media')
MEDIA_URL = getattr(settings, "FILEBROWSER_MEDIA_URL", settings.MEDIA_URL)
# Main FileBrowser Directory. This has to be a directory within MEDIA_ROOT.
# Leave empty in order to browse all files under MEDIA_ROOT.
# DO NOT USE A SLASH AT THE BEGINNING, DO NOT FORGET THE TRAILING SLASH AT THE END.
DIRECTORY = getattr(settings, "FILEBROWSER_DIRECTORY", 'uploads/')
On the browse page, I see the files are in this format:
URL uploads/example.xlsx
Filesize 39.3 KB
But when I click on the URL link, I am directed to
8000/admin/filebrowser/detail/uploads/example.xlsx
with the complaints:
Using the URLconf defined in MIO_Risk.urls, Django tried these URL patterns, in this order:
^__debug__/
^admin/filebrowser/ ^browse/$ [name='fb_browse']
^admin/filebrowser/ ^createdir/ [name='fb_createdir']
^admin/filebrowser/ ^upload/ [name='fb_upload']
^admin/filebrowser/ ^delete_confirm/$ [name='fb_delete_confirm']
^admin/filebrowser/ ^delete/$ [name='fb_delete']
^admin/filebrowser/ ^detail/$ [name='fb_detail']
^admin/filebrowser/ ^version/$ [name='fb_version']
^admin/filebrowser/ ^upload_file/$ [name='fb_do_upload']
Any idea how this should work? or is it supposed to work at all? Thanks
Per the author of django-filebrowser:
clicking the URL is handled by your server (resp. django), not the filebrowser. please check the django docs on how to server media files.
So following this link works like a charm:
https://docs.djangoproject.com/en/1.2/howto/static-files/
Related
Do you think that there is a trick in htaccess to to make the browser download the file my_file_21.pdf if the user access this one with the path http://example.com/files/myfile21.pdf?
And bonus point if the both paths below :
http://example.com/files/myfile21.pdf
http://example.com/files/my_file_21.pdf
works for the file on the server : my_file_21.pdf
I have created my webpage in eclipse as Dynamic Web Project and uploaded the WebContent folder to the server (WebContent contains index.html js, imgs and css). When I call myPage.com, it works only with the url myPage.com/WebContent. Afterthat I have uploaded the content of the folder WebContent directory to the server root. Now when I call myPage.com, it display empty page. mypage.com/index.html display empty page too.
How to upload WebContent, sothat the index.html display woithout using WebContent in the url?
This can be achieved by:
Using URLRewrite. This thing changes URLs according to the patterns you configure. More to read: http://tomcat.apache.org/tomcat-8.0-doc/rewrite.html
Using redirects in the root folder - if someone requested the folder, it automatically sends you to another folder. This can be done by placing index.html in root folder containing: <meta http-equiv="refresh" content="0; url=http://mypage.com/WebContent" />;
Using Virtual Host - description for Tomcat 6.
I already have an awk script called viewzip.cgi which works as follows:
...viewzip.cgi/path_to_zipfile/zipfile.zip/
will show the root directory of that file,
...viewzip.cgi/path_to_zipfile/zipfile.zip/subdir/
shows a subdirectory (if present)
...viewzip.cgi/path_to_zipfile/zipfile.zip/path_to_file/file
will download one particular file.
Now what I want is omitting the "viewzip.cgi" part in the URL and an automatic redirect working as follows:
...path_to_zipfile/zipfile.zip
should download the zipfile as it would be standard behaviour, but
...path_to_zipfile/zipfile.zip/
with the trailing slash should redirect to a path like the first example, and also when trailing subdirs or files are appended.
How can I do that, if so? I have access to file system (i.e. ".htaccess") but not to apache's root configuration files. Or is there a (possibly well-known) better solution? A similar problem applies to .chm files which would be more easily browseable when unpacked on server on request. It would be nice if I don't need to repeat a redirection line for each single zipfile I have.
henni
The RedirectMatch keyword does the job.
RedirectMatch .../((?!viewzip\.cgi/).*)\.zip/(.*) http://www.../.../viewzip.cgi/$1.zip/$2
I've tried some different solutions I've found on the web on my .htaccess file (placed in the root of my website), but I always end up with an "Internal Server Error"...
I need a generic rule to remove a specific folder from the URL and the extension of all the files contained in it (adding a trailing slash at the end), with a redirection to the rewrited url. So, for example:
the folder I want to work on is called "pages", so the rule should not affect any other folder, and I want that the url
http://www.example.com/subfolder/pages/
will be rewrited/redirected to
http://www.example.com/subfolder/
and
http://www.example.com/subfolder/pages/page1.php
will be rewrited/redirected to
http://www.example.com/subfolder/page1/
and
http://www.example.com/subfolder/pages/subpages/page1.php
will be rewrited/redirected to
http://www.example.com/subfolder/subpages/page1/
and so on...
How can I achieve that?
This would be more logical in 2 rules:
Remove extension: /subfolder/pages/(.*).[^.]+ -> /subfolder/pages/$1/
Remove pages from URL: /subfolder/pages/(.*) -> /subfolder/$1
Didn't test the rules but this should get you there.
How do you write rules to redirect all requests to *.php and *.html files in upload/ folder to a text file name forbidden.txt in root www folder. What I'm trying to do exactly is preventing script execution in this dir by redirecting those requests to the text file
Note: The upload/ folder is accessibly by ftp used by a group of people to upload files so I cannot place htaccess inside this folder.
Create an .htaccess file at the root level of your site containing
RedirectMatch ^/upload/.+(html|php)$ http://www.yoursite.com/forbidden.txt
You could also try switching off the PHP engine in that directory by creating an .htaccess file in /upload/ containing:
php_value engine off
although you would need to ensure that people cannot upload files with the name .htaccess
Put your htaccess rules in httpd.conf instead.
If you can't edit httpd.conf, then your best bet is to not allow web access to that directory at all. Let FTP users access a folder outside of your web directory and then provide a mechanism for retrieving the file contents.
You could name that directory "upload". Then you could have your .htaccess file make requests to /upload/myfile execute upload.php, which finds ../upload/myfile and spits backs its contents. This way it would appear to users that they are accessing the "upload" folder directly, but you would the level of control you want through the PHP script.