It's been a while since I created a new directory on my domain (call it my/domain/dir3). I have others, each containing a index.php (dir1/index.php - dir2/index.php), each index is called if the directory URL is called (thus a URL of my/domain/dir1 will call my/domain/dir1.index.php).
No the embarrasing part ... I've completely forgotten how I did this! ... blank .... nothing ... no recollection. Please somebody enlighten me.
If you use Apache, it does this automatically. You can tweak the settings in httpd.conf though.
Well if it's a standard Apache/PHP installation then putting an index.php file in the directory would make it the default page in a directory.
Oh, if you want a different file to be the index. Create a .htaccess file in the directory and enter this:
DirectoryIndex index.html index.htm index.php something.php
Replace something.php with the file you want and presto ;). You can't have two indexes.
If index.php is seen by Apache as the default index file, my/domain/dir1/ will see my/domain/dir1/index.php. If you want something more complex, You'll need mod_rewrite.
Related
For example this is what I type file:///C:/xampp/htdocs/At/html/ in the URL. I want the file:///C:/xampp/htdocs/At/html/pages-login.php to appear. How Can I do this?
The default page is index.html . But you can use any file as default by using .htaccess file.
Create an .htaccess file on C:/xampp/htdocs/At/html/ and put the code,
DirectoryIndex pages-login.php
Now the default loading page will be pages-login.php
The first file the server tries to load is index.html / index.php so on.
So simply renaming your file to index.html should solve that issue.
Alternatively you can keep a index.html which will redirect you to pages-login.html or by .htaccess file you can manage that behaviour.
I have a web-site created with Joomla. I have two different index pages. One of them is "index.php" and the other one is "index.html". I want to set default page as "index.html" when I browse the URL of the site (However, now, the active default page is index.php). I have a href from that .html page to index.php. I have not change the content of index.php.
How can I change it from a configuration page or something like that?
It depends on the web server you are using, if you are using Apache, it's the DirectoryIndex configuration you need to change, see here. For other types of server, I don't know, you'll need to read the docs.
Using an .htaccess file, you can change the index file to something else other than any of the index defaults. To do this, insert the below line into an .htaccess file.
DirectoryIndex index.html index.php
hi all i am purely newbie to right .htaccess files. The issue is,
My base directory is http://localhost/mvctask/and i want to use the files of sub directory sub.
for example:
http://localhost/mvctask/ will be using http://localhost/mvctask/sub/login.php instead http://localhost/mvctask/login.php.
While url remain same as http://localhost/mvctask/. I need it to do without using rewrite-rules.
Please any help.
Edit:
I changed the index.php to login.php in edit. just because there is option to use DirectoryIndex mysubdir/index.php to change index .
I find the solution that same DirectoryIndex is working for all files. While previously i assumed that it works only for index files (may be i confused due to it's name :P ).
DirectoryIndex mysubdir/login.php
I had a index.html page and index.php file are in the same folder .My folder name is Tester and also i had the sub domain with the same name. i am using the following URL www.Tester.hoster.com/ . My issue is, if i use the above link it directly show the .php file. how i display the .html page instead of .php page plz guide me thanks in advance
DirectoryIndex index.html
Add this in your .htaccess file
This is something that you need to update on your server. Depending on if you're using Windows ( IIS configurations should handle this ) or Linux (.htaccess should handle this)
.htaccess:
DirectoryIndex index.html
You can also add more file names/extensions after index.html, they will be treated by priority in the order in which you list them.
Not sure about ISS, sorry.
There are several ways to do it, URL Rewrite being a smart option.
A quick technique is to change the name of the index.php file to something else, say home.php.
I have a small little site I am testing, first time using PHP. It is sitting on an Ubuntu box, in the /var/www folder. I can get to it in my internal network, but I can't get to it outside. I have port 80 forwarded to my Ubuntu box in my router. That is the first question. Second, how do I designate the first page to be served when you get to that box. The default Apache page is index.html. I want a page called login.php to be first. I have renamed index.html to html.old, but then I just get a file listing. Any help, much appreciated.
For custom index page place this in your .htaccess (in root folder)
DirectoryIndex login.php
I don't understand your first question.
For the apache default page, you can either go find your httpd.conf file edit this:
DirectoryIndex index.html
Or you can add the following to a .htaccess file:
DirectoryIndex login.php
2) Delete or move index.html. Rename login.php to index.php or create a new index.php with
<?php require dirname(__FILE__) . '/login.php';
Thats the most basic ways to do this. There are many there solutions, but it seems to me, that this is sufficient in your case.
This works, because the apache by default is looking for several index.*-files (in order).