I have an contact.html file on the server in public_html.If I Move it into directory named: Contact, & rename it to index.html,does browser's Address bar shows it like: example.com/Contact/ ? I mean the name of file doesn't show up.
ANY help is appreciated.
Yes, example.com/Contact/ would work, but only if the server is configured with a default document index.html.
This is standard behaviour for apache web servers.
In your apache config there is a directive called
DirectoryIndex index.html ...
This tells the webserver to serve index.html in the case that a directory call was requested ... ie your example.com/Contact/ [Is a directory].
To change that behaviour you would need to look into change your server config, or adding an .htaccess file that would rewrite the URL to index.html
Related
I was learning about HTML domains and paths in my computer-science class. However, I have a question. What happens if you only specify a domain, such as apple.com instead of specifying a path? Does the page automatically give you the index file or something?
Thanks :)
That entirely depends on what the web server is configured to do. What you’re doing is you’re requesting a URL from a web server via HTTP. That does not inherently have anything to do with files. The web server can respond to the request in any way it wants.
But yes, most typically the average web server will look for a file named something like index.html in its webroot folder and return it.
yes, there is the default file that is returned if no path is provided
From Apache documentation
Typically, a document called index.html will be served when a directory is requested without a file name being specified. For example, if DocumentRoot is set to /var/www/html and a request is made for http://www.example.com/work/, the file /var/www/html/work/index.html will be served to the client.
From IIS documentation:
Default documents are enabled by default, and IIS 7 defines the following default document files in the ApplicationHost.config file as server-wide defaults: Default.htm, Default.asp, Index.htm, Index.html, Iisstart.htm.
(If you install ASP.NET on your Web server, the installation process will add the Default.aspx file to this list.)
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
Is there a way to have a file other thing index.html or index.md served as a folder's default file? Specifically, I'm looking to keep my .json file extention, but have it reference-able as /api-docs/myapi/ instead of /api-docs/myapi/myapi.json.
This configuration is mostly in your web server. You can set the files for the server to look for to index.json (as well as index.html and index.htm which are common on most servers). For example, this can be configured on nginx by adding this to your server block:
index index.json index.html index.htm;
If nginx gets a request for /some/folder, it will try to serve /some/folder/index.json, /some/folder/index.html, /some/folder/index.htm then your 404 page with this configuration.
You can use permalink in your yaml front matter :
Permalink: api-doc/myapi/myapi.json
Edit: As #SAMdroid pointed it, I misunderstood the question, and as he says in is answer, it's a server configuration matter. But, it's sadly not possible to change default served page on Github Pages.
Your json can only be reached at api-doc/myapi/myapi.json
I have installed XAMPP , there is a htdocs folder and inside it index.html file ,
when I try to open it in my browser through http://localhost/xampp/htdocs/index.html it says
unable to connect to localhost .
what is wrong ?
instead of
http://localhost/xampp/htdocs/index.html
try just
http://localhost/index.html
or if index.html is saved in a folder in htdocs then
http://localhost/<folder-name>/index.html
htdocs is your default document-root directory, so you have to use localhost/index.html to see that html file. In other words, localhost is mapped to xampp/htdocs, so index.html is at localhost itself. You can change the location of document root by modifying httpd.conf and restarting the server.
Start your XAMPP server by using:
{XAMPP}\xampp-control.exe
{XAMPP}\apache_start.bat
Then you have to use the URI http://localhost/index.html because htdocs is the document root of the Apache server.
If you're getting redirected to http://localhost/xampp/*, then index.php located in the htdocs folder is the problem because index.php files have a higher priority than index.html files.
You could temporarily rename index.php.
You need to start your Apache Server normally you should have an xampp icon in the info-section from the taskbar, with this tool you can start the apache server as wel as the mysql database (if you need it)
All created by user files saved in C:\xampp\htdocs directory by default,
so no need to type the default path in a browser window, just type
http://localhost/yourfilename.php or http://localhost/yourfoldername/yourfilename.php this will show you the content of your new page.
You should simply create your own folder in htdocs and save your .html and .php files in it. An example is create a folder called myNewFolder directly in htdocs. Don't put it in index.html. Then save all your.html and .php files in it like this-> "localhost/myNewFolder/myFilename.html" or "localhost/myNewFolder/myFilename.php"
I hope this helps.
I just put an index.html file in /htdocs and type in http://127.0.0.1/index.html - and up comes the html.
Add a folder "named Forum" and type in 127.0.0.1/forum/???.???
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