only file name index.php is not working on apache2 - php

I'm using apache2 on ubuntu. My localhost is working fine and also php is working.
But only file name index.php is not working. If the file name is test.php or anything othe than index.php, it works.
Dont know it is apache prob or php, can anyone please help?
Thankx,
Kamil

Avoid the htaccess file and edit http.conf. It should be the same listing DirectoryIndex there too. Add index.php and see if you get php to render.
Out of curiosity what do you see when you view index.html? It works! ?

Do you mean it's not recognized? You can try to add it to your .htaccess file in the root of your webserver:
DirectoryIndex index.php

Related

convert rules from htaccess to nginx

hope somebody can help me, in transforming my apache htaccess rules to nginx config
Removing the .php from the url's, so url: "/contac"t displays the file contact.php
Make this paths use their respective php file, for example:
"/products" shows the file products-all.php
"/products/some-category-name" shows the file products-cat.php
"/products/some-category-name/product-name?id=89" shows the file products-detail.php
I tried searching everywhere, but couldn't fine the correct answer, appreciate any help
Thanks
Check following links:
htaccess to nginx

Laravel 5 showing directory structure instead of index.php on xampp localhost

http://localhost/laravel_test/
Instead of routing to the index.php above URL is only printing Index (Directory Structure) of /laravel_test.
I am able access the index page with following:
http://localhost/laravel_test/public/index.php
I tried modifying the .htacess file by adding following line inside the public directory of laravel_test still no change:
DirectoryIndex index.php
This is an old post, but in case this helps anyone, I was facing this problem because my httpd-vhosts.conf file was pointing to C:/xampp/htdocs/MySite instead of C:/xampp/htdocs/MySite/public. This is stupid mistake but you know everyone does this kind of mistakes once in a while.

site only shows all info from index.php?

Sorry if this is a basic question, but Im wondering why my site doesn't display correctly unless I utilize the index.php extension. Here is an example :
www.copishboutqiue.com/salon
which displays incorrectly but
www.copishboutique.com/salon/index.php displays the correct layout we're using. Why do I need to use the index.php when this is the only file in the root directory?
if you are using an apache server create a .htaccess file in the root directory of your website and add
DirectoryIndex index.php

xsendfile won't work with mod_rewrite

I'm trying to send file from a rewritten URL.
Inside the .htaccess file I have:
RewriteRule ^foo$ foo.php [L]
In foo.php:
header("x-sendfile: ".$_SERVER["DOCUMENT_ROOT"]."/filesdir/test.txt");
When browsing to foo.php directly I see the content of the file, but when browsing to /foo I get 404.
I've tried to search the web but couldn't find any solution for this other than redirecting foo to foo.php
does anyone knows what's the problem and how to solve it?
I solved the problem.
In httpd.conf there was XSendFilePath directive which was a resolved symbol path while in the php there the "filesdir" was actually a symbolic link to the path in XSendFilePath.
I've add the symoblic link to XSendFilePath and now everything works well!

Two basic PHP, Apache on Ubuntu questions

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).

Categories