Disable viewing directory tree via url - configuration

I bought a domain name and am trying to figure out how to configure it responsibly. I haven't set up an index.html file yet and I've noticed that if I hit my domain, I see my file directory tree and I can dive down to all the files within my browser. Is there a way that I can disable this? I am hosting it on Apache

If you are using IIS.
Right-click on your website, and choose Properties.
Select Home Directory tab.
Uncheck the Directory browsing.

You can try a few things:
create an empty file named index.html and upload it into the public_folder
create an .htaccess file with the following contents: Options -Indexes
If you have some kind of cpanel for your site, look for options to disable directory browsing.
Creating the index.html file is probably the easiest and most consistent way to go.
FYI, my .htaccess info came from techiecorner.com

Related

How to make domain url lead to index.html?

How can i make that with entering mywebsite.com it leads to mywebsite.com/index.html?
I'm using siteground and I was recommended htacess but I'm really new at web programming, I don't know what that is and I really don't know what to do
In the Root folder of your website (on the server itself) is a file named .htaccess
That file contains information for the server, about which files and folders are accessable from the internet.
.htaccess can only be accessed when you are logged into your server account. It is a textfile in the Root folder of your hosting area.
In the file you can route all incoming traffic to index.php or index.html or whatever you like.
Here is some more info https://httpd.apache.org/docs/current/howto/htaccess.html
You will need to create .htaccess file in the directory of the website.
Inside it, at its very top, you should add:
RewriteEngine On
DirectoryIndex index.html
That will lead anyone to yoursite/index.html.

My website doesnt load index.html if i dont write it manually

I recently bought a website to play with, but I immediately had a problem.
My website doesn't load the index.html when I just connect to mydomain.com. If I write it manually (mydomain.com/index.html) everything works perfectly. I tried to change the .htaccess file to direct all traffic to my index.html page with the following line, but the problem remains:
DirectoryIndex index.html
Any ideas to solve the problem?
Please provide the web host and/or server type (windows, linux, etc) to help further answer your question.
As a start some web servers (windows/iis) expect different file names for the default html file. Godady.com has a list of different file names for Linux and Windows at this url: https://www.godaddy.com/help/what-file-displays-when-someone-browses-to-my-domain-name-60
Good luck!
This DirectoryIndex index.html has to be set in httpd.conf file. In your httpd.conf, you might have disabled .htaccess with AllowOverride none. That is why your .htaccess is not working

Access htaccess of another website

How do I download an htaccess file from another website?
How do I view my own htaccess in my browser?
I have tried to go to www.website.com/.htaccess but no success for example.
I know that there is a command that can be added to the htaccess file to disable viewing but I'm talking about htaccess files that do not include this code.
By default, Apache config has
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ".ht*">
Require all denied
</Files>
So you can't, or you shouldn't be able to. It would be a security problem otherwise.
How do I download an htaccess file from another website?
That's not possible, .htaccess can contain sensitive information, that's why the default configuration prevents access to this file.
How do I view my own htaccess in my browser?
You can modify the server configuration (see how to configure apache to view hidden (.) files?) to unblock access to this file. But if you have access to this configuration, you probably have an access to the file, so you should be able to view it with another tool than your browser.

Basic HTML - does relative path to a sub-folder (using the directory name) work on a desktop?

I am doing some basic HTML exercises on a Mac OS 10.6.6.
Say I am here:
rootfolder/index.html
and I want to go here:
rootfolder/subfolder/index.html
I understand I can use the relative path to make a link:
link to subfolder
^ this works for me in my browser.
And if I wanted to shorten the href, I could just do this:
link to subfolder
When I click the short version in my browser, the link takes me to the folder on my desktop (not to the page in my browser)
I'm wondering, do the files need to be in a web host environment for
the short version to work in a browser?
When /bob/ => /bob/index.html works, it is generally because the server has listed it as its directory index, e.g. with Apache...
DirectoryIndex index.html index.php
...meaning in the request of a folder, it will first look up to see if an index.html or index.php exists (in that order).
So if you are running it from the folders of your local filesytem (i.e. on the file: protocol), it has no server and does not know that a blank directory should request index.html.
The serving of index.html (or index.cgi or default.asp or whatever) when requesting a url that points to a directory is done by the server, not the browser. It is usually done as a result of configuration setting.
It's neither a property of HTML nor a property of urls.
If your browser doesn't serve index.html — and I don't know any that do — then you've answered your own question.
Mac OS comes with Apache (the most commonly-used open-source web server) pre-installed. You can set it up by going to System Preferences, choosing the "Sharing" preference pane, and then checking the box to turn on Personal Web Sharing.
Once you've turned on Personal Web Sharing, http://addressofyourcomputer/~yourusername/ will point to the Sites directory in your user's folder in Mac OS (i.e., /Users/yourusername/Sites/). With Apache running, if you go to http://addressofyourcomputer/~yourusername/subfolder/, it will in fact serve up /Users/yourusername/Sites/subfolder/index.html if there is an index.html file in that subfolder.
Without turning on Personal Web Sharing, though, there is no server running, and so your browser is really just directly accessing your computer's filesystem. As a result, when you ask for a folder, it literally returns you that folder, whereas Apache server knows the convention that /subfolder/ is really a request for /subfolder/index.html and will re-direct you accordingly.
The default page setting/redirection works only on web servers. The browser do not have intelligence(?) for such redirection. So the second option will not work.

html showing contents of folder

i am creating a web page to show the contents of a folder so that people can view the files and download them if needed.
Click here to view Folder
But i wanna do this without any coding what so ever, i found this code which lets me view files.
The problem i am facing is that when i double click the html page and open it this hyperlink works and i get what i need but when i access the page through a server (IIS 7) then the hyperlink does nothing ?
am i to set some permissions or what ?
can someone tell me what im doing wrong ?
The link will work when the file you want to download is on your own personal computer, which in your case is true if you're just showing the HTML file locally. It won't be true for users visiting your website from another computer though.
If you want to serve the file on a server, you need to link to the path on the server itself, that is, if the file is in C:\inetpub\wwwroot\test_pages, your A HREF looks like this:
Click here to view Folder
Offcourse, this will work for simple files. For folders, you need to enable the webserver to show directory contents by enabling Directory Browsing.
There are security implications of linking to a local file from an online source. It works when the page is held locally but when on a server it puts a stop to it.
You can also use linux build-in command Tree, in example below you can see that i only want to add files that are matching .tar.gz or .zip or .tar.bz2
tree -P "*.tar.gz|*.zip|*.tar.bz2" -h -D --dirsfirst -r -H . > index.html;
You can also add a custom css to the page for a better looking output.
Straighforward and highly secure since the result is only html
as you use windows you can use www.cygwin.com to emulate a linux environement