joon1
December 11, 2020, 9:52pm
1
I have 2 pages at the same directory like the above.
At myPage.php I have the code below.
<a href="index.php">going to index</a>
If I click the link above, it will go to localDirectory/index.php.
Since “index.php” is a default page, It is possible, I think, to make it omit the default page name, i.e “index.php” in the code.
the code below are two of my trials for it.
trial code1
<a href="/">going to index</a>
The code above is not going to localDirectory/index.php, it goes to root/index.php.
trial code2
<a href="">going to index</a>
The code above is not going to localDirectory/index.php, it goes to localDirectory/myPage.php
trial code3
<a href="/localDirectory/">going to index</a>
The code above is possible to going index.php.
But I don’t like it because I should change the path when I move the project to another directory,
Erik_J
December 11, 2020, 11:05pm
2
joon1:
trial code1
<a href="/">going to index</a>
The code above is not going to localDirectory/index.php, it goes to root/index.php.
The / is what you should use as path to the root and let the default page open, often named index.html or index.php or other names in a priority order.
In your local setup, the root seems to be localDirectory but for the live site the host directory, where you place the whole site, is the root.
The site’s root directory in you dev machine is set in your virtual host configuration file and in the machines (OS) hosts file.
Maybe this thread here is of interest:
Hi,
I am working on a local server on my Windows 10 computer for building and testing websites. I have Apache + PHP + MySQL setup. The site folders are in htdocs folder of Apache.
My issue is that I work on multiple websites during the day and currently, whenever I want to work on a website, I move its files to htdocs folder. When I want to work on another website, I remove the previous website’s files, and move in the other website’s files, etc.
I use http://localhost/ as the root of the web…
1 Like
SamA74
December 12, 2020, 11:14am
3
You can define the default home/index page in htaccess.
DirectoryIndex index.php
3 Likes
system
Closed
March 15, 2021, 5:29pm
5
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.