Not opening folder in localhost - php

I just installed WAMP server to start practicing PHP. I created a folder in www directory. However, when I try to run the file from localhost it does not run.
For ex, I created a folder "test" in www directory. I saved an php file called "test.php" inside the test folder. Basically I have saved it in www --> test --> test.php.
I started localhost in my browser. I found test folder there. But when I click that test folder, instead of opening as "localhost/test", it is opening as just "test/". How to make sure that the folder, when clicked inside localhost, should open as "localhost/
When I type as "localhost/test" in my browser, it works fine. But when I go to localhost and click on "test" folder it does not open.
Please help me to overcome this.
Thanks in advance

Just create new virtual host in wamp using your current directory path to test directory.

Related

How to run a php project in localhost using XAMPP?

First of all, I'm using Kali Linux. I have a project, it's a folder with .php files. I want to run it to see it on the browser, so it needs to be localhost. Folder name is "CMSsite". I moved the folder to /opt/lampp/htdocs folder to access it through typing on the browser localhost/CMSsite. When I open the browser and type localhost/CMSsite/ I see the message "The requested URL was not found on the server"
enter image description here
How can I solve this problem?

Why my localhost is unable to recognize my htdocs in its directory?

I have a problem with my XAMPP server after uninstalling an old version for a new one. I have a problem with executing PHP codes because when I put "localhost/file.php" it says "Object not found" or put the PHP document despite having the Apache server on.
When I access the XAMPP directory from localhost, it's completely empty despite I stored the site in the htdocs folder. And if you ask, the xampp folder's location is C:/xampp/. And I did put an .htaccess file in my file's directory.
Here's a screenshot:
xampp -> apache -> config -> apache(httpd.conf) and search DocumentRoot and Directory.
see there what link is set.
Giving localhost in the browser address bar refers to htdocs folder.
As we can see the address as localhost/xampp i.e you are refering to htdocs/xampp
if you have stored your file in htdocs root folder, then give the address as localhost

localhost does not render website, only index of, using mamp

Using mamp, I have my document root set to htdocs folder. Inside that folder I have the folder with the contents for the site. When I connect to localhost, the page that renders is "Index of /" and then a bullet point with the name of the folder within htdocs.
How can I get the full page to render? What am I doing wrong?
A request to localhost looks for files in the htdocs folder. If it doesn't find an index file (html,php,etc) it displays all the folders in the directory. If your website lives at htdocs/mywebsite then you need can view the website at localhost/mywebsite.
Otherwise you can move the entire contents of mywebsite into the htdocs folder itself.
it sounds to me that you have put your files in a folder in the htdocs
so to access you need to point your browser to the folder
instead of localhost/mywebsite
you would need to type localhost/mywebsite/thenameofyourfolder
In MAMP preferences, have you set the root folder to the folder you are attempting to serve?
Ensure your httpd and hosts files are configured correctly too!
nano /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

PHP localhost issue. Folder not opening when clicked inside localhost

I just installed WAMP server to start practicing PHP. I created a folder in www directory. However, when I try to run the file from localhost it does not run.
For ex, I created a folder "test" in www directory. I saved an HTML file called "test.html" inside the test folder. Basically I have saved it in www --> test --> test.html.
I started localhost in my browser. I found test folder there. But when I click that test folder, instead of opening as "localhost/test", it is opening as just "test/". How to make sure that the folder, when clicked inside localhost, should open as "localhost/<foldername" (in this case "localhost/test").
When I type as "localhost/test" in my browser, it works fine. But when I go to localhost and click on "test" folder it does not open.
Please help me to overcome this.
Thanks in advance.
You should type the file name and the extension to open the file from the local host as your file is not index.html
so you should go to "localhost/test/test.html" that would work
if you want your file to

xampp is not showing .php files saved in htdocs folder

I am using windows 7 and just installed xampp server to "E:\xampp" in my laptop to learn php. Now the problem is whenever I start xampp server by starting "xampp_start" in xampp folder and start Apache and MySQL from "xampp-control" and type localhost in my browser it automatically gets converted into "localhost/xampp/" and display a default page instead of displaying the .php file which I created in htdocs folder. Another problem is when I created a folder in htdocs folder and saved a index.php and another .php file which was created by me, it is not showing that folder too. I know this question has been asked before but I didn't get any solution from there because I started xampp_start from xampp folder and Apache & MySQL from xampp-control. So please help. Thanks in advance.
This is the default picture which is being displayed:
Thing is if you create any .php file in htdocs folder, you have to run that file as "localhost/filename.php" but if you created any folder in htdocs, for example folder name is "work" then you have to type "localhost/work/" and then it will show file contained in that folder.
First copy the files of htdocs and paste on any drive and delete the htdocs folder then create another folder and paste the files in this folder and restart the server.
First make sure you go to Local Disk (C:), then go to xampp -> htdocs-> and create your folder.
Hi Guys Here Iam Gonna Show You How You Can Fix This Error
Follow me
Don't worry ! If xampp is not showing .php files in htdoc/folder OK:
Just change the name of that file which is not showing and refresh or reopen the localhost directory it will-be show
Your file
If this method work or not comment below
Good luck and keep it up.
#gamerinc

Categories