I've been searching and I haven't found a solution that fits my need right now.
I have a website www.mywebsite.com and all its files are inside the public_html folder.
I want to create a folder called "uploads" inside public_html and then BE ABLE TO ACCESS it with www.mywebsite.com/uploads
I want it to list all the fles I've put there via FTP, but right now it shows me FORBIDDEN.
How can I be allowed to see the list of files and folders?
Thank you.
Related
I want to disable access of a specific folder of my domain say: mydomain.com/newsletters/
BUT since i will be adding files inside /newsletters I want all files to be accessible.. say: mydomain.com/newsletters/april-newsletter.pdf
Thank you in advance.
On my xampp server, I have several folders in /projects/ with different projects. The problem is when I make the link to the home page, I can't simply put in / because instead of going to localhost/projects/currentproj/, it goes to localhost.
Normally, I would just set all the href links to /localhost/projects/currentproj/, but I upload this project to a website so the website would have an incorrect link. I have temporarily set the links as local ones, with ./ instead of /, but I would like a more permanent solution if possible, and I don't know how to format htaccess files.
In other words, I would like to know how to change the root of a subdirectory, so all files in that folder go to the root of their own folder when linked to the root, rather than leaving that subdirectory.
EDIT:
Here is a perfect example of why this would be helpful.
That is what my 404 page looks like when I go to localhost/projects/currentproj/sub/example. If I could use / for the root of the currentproj folder, this wouldnt be an issue.
Here is an example of someone else with the same issue, but they never got a proper answer. There has to be a way to change this in the htaccess file.
I'm working with a webpage that uses a content management system. The webpage belongs my university. We want create a private file with .htaccess and htpasswd.
The problem is I can't figure out how to place the htpasswd file outside the webpage files because I don't have access to the server machine. I need to do that because someone told me it is unsafe to place it within the webpage files. Any ideas?
If you have a shared hosting account for your website, I suggest you connect to it through FTP. In Directadmin as example, you have to put the file in your public_html folder (which is the root directory of your site).
In case you want to put it outside of the root (as you were asking), place it 1 directory lower (so not in the public_html but before that), and then link it to it.
In case you lack the permissions to do so, contact your hosting provider, cause he should be able to do it for you (and ask him for the direct path).
I wish to protect folder with core files of CMS and its sub folders and files from accessing via web, and I tried with .htaccess file with this:
order deny,allow
deny from all
Problem I have is that I can protect that folder but some script from that folder or its sub folder then do not work good.
I also tried with this:
order deny,allow
deny from all
allow from 127.0.0.1
allow from 76.xx.xx.xx
In this case 76.xx.xx.xx is static IP of site.
Is there any way to prevent accessing files in that folder but still to make all work ok?
Another question.
I wish to secure more my site from hackers. So, is there any way to prevent injecting malicious files and code in my scripts/files and/or to block my site of executing files from other sites, hosts, to allow just working with local files.
I prefer .htaccess file, but if it is needed I have access to WHM if there is need for editing other files (but in that case I will need step by step guide). I am running site on Linux VPS with Cent-OS 5 system.
The usual way to do this is to put the accessible files in an apache-accessible directory, but all the rest into a directory out of the way from Apache. For example:
/usr/
local/
mycms/
public/
lib/
/var/
www/
mycms -> softlink to /usr/local/mycms/public
Or better yet, make mycms an alias in Apache config, pointing at the public directory. This way, the files that should be accessible are, those that shouldn't be aren't, and you can still reference all your other files simply by ../lib/ etc.
I know this does not really answer your question literally, and if the CMS directory structure is not under your control, this may not be the best way to do it.
Another way is through rewrites - simply rewrite all requests to your CMS directory except for your CMS's entry script into requests for the entry script.
In my root web folder I have a list of folders (files, modules, classes) that I'm using .htaccess to prevent access to. However, in the modules/ folder, there are modules that carry their own images, which I'd like to allow access to.
How do I allow access to images in a folder under modules/, but still prevent accessing any other files in that same directory path?
Try this in your .htaccess. It should let you grant access to images within the directory. You may need to tweak this to make it work for you.
<FilesMatch "\.(gif|jpe?g|png)$">
Order allow,deny
Allow from all
</FilesMatch>
I believe if you read this document: http://httpd.apache.org/docs/1.3/howto/htaccess.html you will gain insight as to how to achieve the access permissions you desire.
To sum it up, without rewriting the document: you can allow access to the directories that you wish either through .htaccess files in those folders, and .htaccess files can be placed at any level in your directory tree.
Further, the article also makes some suggestions that may perform better by using your main server config file instead of .htaccess files.
Hope this helps,
-james