apache2 is not listing the director - php

when we give ip in browser its not pointing to the index page. It showing error : "Not Found The requested URL / was not found on this server" though index page is there in DocumentRoot.
If we give ip/index.php, it shows the page. Similarly when i opened test directory containg some files in browser (url : ip/test),it showing same error "Not found" instead of listing the files in the directory.
Autoindex module was enabled .
Tried giving Options +Indexes // enables the listing of files/folders in a directory
Permission for the directory also enabled.
But still got the same error. When checked with log file , whenever i tried to open directory, showing "attempt to load directory"..But its not loading.
[This was happening with test server ,whereas stage server working properly. Also compared test and stage server configuration files like default [/etc/apache2/sites-enabled] , .htaccess , apache2.conf , httpd.conf, evrything seems to be same. ]
.htaccess file
`Options +FollowSymLinks
DirectoryIndex index.php`
log file
Attempt to serve directory: /var/www/
Document Root : /var/www/
Would someone have an idea to fix that one. Thanks in advance

It appears you need this line on top of your DocumentRoot/.htaccess:
DirectoryIndex index.php
This will by default load index.php in each directory if request is for domain.com/somedir or just domain.com/

Related

Webiste url are not routing without index.php

I uploaded my website from my UAT/Test domain to EC2 AWS. Before everything was fine, but now only home page opens.
And if I try to navigate to any other links I can't, it gives following error
The requested URL /page/company was not found on this server.
But when I insert index.php in between it works fine.
Any ideas?
Please enable mod_rewrite module in your server and rewrite index.php in htaccess file.
Please check your file premissions
I believe the issue could be DirectoryIndex which apache (not positive that is what you are using as web server) uses to direct the user to a specific file if a directory is selected in the URL.
This can be set in your apache config if you have access, or in a .htaccess file if you only have access to the your webspace itself.
http://www.htaccess-guide.com/directoryindex-uses/
Basically with DirectoryIndex you can tell apache to automatically use index.php, or index.html, or really whatever file you want to be used when no file in a directory is given in the URL.

Can't open index.php file from Mobile browser

I have a web application. It's back-end is in PHP. There are some directories inside the application. Some of the directory has index.php file. The Problem is when I am trying to route users to other .html pages in the same directory it's working fine. Now one of the directory has index.php file and in the link I have given the relative path to the folder (So by default it is loading index.php file in that directory from Desktop,Labtop etc) but it is not loading that page when I try to run the same from any mobile browser. After Inspection I realized that I can see somefolder/index.php in the address bar while in mobile it is just till the somefolder i.e it is not trying to load index.php file due to which I get "Not Found" 404 error
You have to set your DirectoryIndex correctly. When calling the directory from an web accessible URL without any file name, it tries to access your DirectoryIndex file, per default it is called index.php, index.html, index.htm, index.cgi etc.. This depends also on your platform. Different systems have different default DirectoryIndex configurations. If those index file does not exist, you should see the directory listing in the web browser, even if the web server user has the rights to list the content of the current directory (special bit under Linux/UNIX and maybe protected by advanced kernel security applications like selinux or AppArmor).
What happens, if you try to access the folder directly without any file name from an desktop browser? Will you get there the HTML output of index.php?

Avoid Directory listing in a shared server

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.

access directory of a webpage

I am looking for a way to access a folder in a site that contains index.html or index.php .
But when I remove the index file, when I try to access list of contents from the url, I get
404 page not found
error ;
Is this possible to see contents of a folder with features that I said , if yes why ?
You could enable directory listing in your .htaccess file that you would put in the directory that you want to browse:
Options +Indexes
But the fact that you are getting 404 error might also mean that the directory doesn't exist at all on the server. So make sure it exists and has a .htaccess file inside it allowing directory browsing.

Hide open directory

I have a website and right now users can just open a directory and see all files in it. How do I disable that?
I was thinking about the php.ini file, or generally any php configuration that might do the trick (it is an Apache server run with PHP).
Disable Indexes option in apache configuration.
Put this either in your httpd.conf or .htaccess in the root of the site.
Options -Indexes
This way, if the folder does not have an index page, the user will get a 403 Forbidden error.
Put a text file named .htaccess to your root-dir of your website or the dir you want to hide with following content:
Options -Indexes

Categories