Open website in browser directly when http://localhost is input - 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)

Related

.htaccess DirectoryIndex /subfolder/index.php seems to manage links in a funny way

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.

Index.php file is missing in localhost while url is redirecting?

we have a website. while am running it in my local host, for every redirected url there is missing index.php file. if i put the index.php file in redirected url its working fine. but if i click on any other tabs/widgets again getting the same problem and every time i have to add this index file in url. when i launch my website using http://localhost/zimplee/trunk/index.php url, it will open the home page fine. after clicking on login tab url will redirect to http://localhost/zimplee/trunk/customer/account/create/. what is the problem i couldn't find it. please help me
If on Apache, probably you didn't provide DirectoryIndex setting in apache's config file (Usually, httpd.conf). Insert this into it:
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
You can delete index.html if you don't need static files to be used for output.
You can read about DirectoryIndex in documentation

Filezilla folder

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.

Typing localhost in browser should send me to main page of my PHP project

I have a PHP project which has many files. I have configured it properly and it's working.
But I want that whenever I type (only) localhost in my browser, it should lead to the main page of my project.
Right now, the scenario is whenever I do that, it shows the php directory like this:
Index of /
adddet.php
client/
dbconn.php
deldet.php
login.php
main.php
I will just assume you are using Apache as your web server.
Rename main.php to index.php or adjust httpd.conf like follows.
DirectoryIndex index.html index.htm default.htm index.php index.pl main.php
You need to use DirectoryIndex directive under Apache to set a default page other than index.html or index.php.
You could also use the rewrite enigne of apache2:
RewriteEngine On
RewriteRule ^(.*)$ /main.php [R,L]
Best regards!

How to hide a .php, .html or .text file from an external web user

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

Categories