I have created a website and I already bought the domain and the host. Now I'm trying to upload my website (in the folder "Mywebsite" ) To the server via Filezilla.
In my folder "Mywebsite" I have index.html, faq.html, contact.html and other things.
I uploaded the files on the server, in the folder called public_html. Now if I go to check my website, I can see this folder menu here.
Now if I click the "index", I can see my homepage of the website ( but this should happen when I open my website, right? ) or if I add /index.html in the url. Anyway that's my problem. I just want to know how to set the page index.html when I open www.mywebsite.com.
You can use Apache's DirectoryIndex directive, for example:
<IfModule dir_module>
DirectoryIndex index.html index.htm index.xhtml index.php index.php3 index.php4 index.php5 index.phtml
</IfModule>
The DirectoryIndex directive sets the list of resources to look for,
when the client requests an index of the directory by specifying a /
at the end of the directory name. Local-url is the (%-encoded) URL of
a document on the server relative to the requested directory; it is
usually the name of a file in the directory. Several URLs may be
given, in which case the server will return the first one that it
finds. If none of the resources exist and the Indexes option is set,
the server will generate its own listing of the directory.
Related
I have the default myIndex.php in a subfolder of public_html.
I added a file .htaccess in public_html.
I added DirectoryIndex /subfolder/myIndex.php in it.
myIndex.php contains links and includes.
Includes seems to work but links dont: no images and no css but menu.php is included. Links in menu.php dont work either.
If I
change .htaccess to DirectoryIndex index.php,
create a file index.php in public_html,
and put a link to "./subfolder/myIndex.php" in it
everything works fine.
I dont understand what happens here.
DirectoryIndex determines what to do, when a client requests a directory. If you have
DirectoryIndex /subfolder/myIndex.php
then exactly this script will be executed every time the client requests a directory, no matter where this directory is, e.g. /anotherfolder/ or /static/.
But when you have
DirectoryIndex index.php
instead, Apache looks for an index.php in the requested directory, e.g. /anotherfolder/index.php or /static/index.php.
I am using xampp and i have a website in htdocs.
The home page home.html is in a folder website -> website/home.html. I want to host that website in xampp, so my question is, how to access the home page home.html directly.
Is there any modification that need to be done?
You'll just have to move your home.html to the htdocs folder (just simple move it outside your website folder) and then make sure to rename it as index.html.
Since index.(php/html) would be automatically be opened once you access your localhost.
But take note this will replace the XAMPP's default index page which is not a problem (unless you want to make use of it).
Are you saying that you want home.html to open as the default page when browsing to http://localhost? If so, you'll want to add home.html as a Directory Index file. In standard Apache HTTPD server configuration, you'd just look for a block looking like:
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
Just add home.html to the end of the DirectoryIndex line, so you'd get:
<IfModule dir_module>
DirectoryIndex index.html index.php home.html
</IfModule>
The location of your httpd.conf file, where you'll need to make this change, depends on your XAMPP installation.
If this is not your question, you'll need to provide more specifics.
Although it might be preferable to change virtual hosts, a simpler solution would be to use an HTML Redirect. Create, in the htdocs folder, an index.html file with this line in it
<meta HTTP-EQUIV="Refresh" CONTENT="0; URL=http://localhost/website/home.html">
(assuming that localhost is reachable and the structure of the directory is htdocs/website/home.html)
I am using shared server for my website and therefore i dnt have access to my httpd.conf.
my director r getting listed like
when i click on mysite.com/xyz/
all php files are showing.
Please help
in your .htaccess file add
Options -Indexes
To follow up and more thoroughness, you can also use an index file in the directory by creating a blank index.html file.
e.g. index.html
Or you can also specify the exact file and orders you want to be the index in htaccess with
DirectoryIndex index.html index.php
So there you have a few choices. The file will have to exist and it can contain anything or nothing.
If I open my URL http://example.com/, it shows my all sub directory like below
Index of /
• data1.php
• data1.txt
I want if any web user search like “http://example.com”, it will automatically forwarded the like http://example.com/data1.php. By this way I want to hide my all php, html or .text file form external web user.
You need to have a .htaccess file in the web root and just keep this as the first line
DirectoryIndex home.php
Also you can make changes in the your httpd.conf file
<IfModule dir_module> #Keep adding pages here, it will read from left to right
DirectoryIndex index.php index.php3 index.html index.htm
</IfModule>
but you better stick to .htaccess instead
Not required but you might also like to deny directory listing you can use this
#Block Directory Listing
IndexIgnore *
If you have permission to edit the master configuration files
Edit the files httpd.conf and srm.conf file and do the following:
Find this line.
DirectoryIndex index.html
Change it as follows:
DirectoryIndex index.shtml index.html
Of course, you can use any filename you wish. I prefer to leave index.html as a valid index as well.
Changing The Default Page using .htaccess
If you are unable to edit your master configuration files, you can use this directive from .htaccess. Just edit the .htaccess file located in your main HTML directory. If you do not have this file, feel free to create it!
To change the default page, either edit the existing DirectoryIndex line or add the following:
DirectoryIndex index.shtml index.html
This will make index.shtml the default page.
By using a .htaccess file in a subdirectory, you can specify a different default page for that one directory without affecting the rest of your site.
Font: http://bignosebird.com/apache/a2.shtml
I get my web site appears only by typing the following: www.example.com/index.php
when typing: www.example.com nothing happens.
How to call index.php on startup by typing my website's address.
Create a .htaccess file and put it in your server root. Add the following to the file:
DirectoryIndex index.php index.html index.htm
In the server section of your nginx.conf (or whatever file it includes), make sure you have the line:
index index.php;
You ARE running nginx, aren't you? ;-)
While you have not provided any technical details on your web server, I would suggest looking into DirectoryIndex.
The DirectoryIndex directive sets the list of resources to look for,
when the client requests an index of the directory by specifying a /
at the end of the directory name. Local-url is the (%-encoded) URL of
a document on the server relative to the requested directory; it is
usually the name of a file in the directory. Several URLs may be
given, in which case the server will return the first one that it
finds. If none of the resources exist and the Indexes option is set,
the server will generate its own listing of the directory.
Example:
DirectoryIndex index.html index.php
A request for http://mysite.com/docs/ would return http://mysite.com/docs/index.php if it exists, or would list the directory if it did not.