uhttpd config, index file, php vs. html

Hi, in my Yun I installed PHP and it work fine..
Now I have a question:

If I put in the /www dir a index.php file and then go to http://my.yun.ip , the webserver redirects me to: http://my.yun.ipcgi-bin/luci/webpanel/homepage because in the /www dir there is a index.html file that does the redirect ..

How can I set index.php priority instead of html files ?

I tried to set in the /etc/config/uhttpd file the "option index_page" or "option index_file" as described here: Web Server Configuration (uHTTPd) [Old OpenWrt Wiki].
After saving changes, i always did a utttpd restart but no one solution worked...

The output of

uci show uhttpd

if you are missing:

uhttpd.main.index_page=index.php

then need run:

uci set uhttpd.main.index_page=index.php
uci commit 
/etc/init.d/uhttpd restart

empty cache of browser, at chrome clean the History, restart browser and visit http://ip_address_yun/.

thanks for the reply... the command

uci show uhttpd

didn't display the index_page=index.php...
I tried again to add the line:

option index_page       index.php

to the config and restarted it....now it works... (maybe before i did some mistake!)

now the command output is: uhttpd.main.index_page=index.php

Hi, another time here because my old problem become my new problem...the situation:

/www folder is like original, with the index.html that works properly with the yun control page (I can connect using http://yun.ip/)

/www/keystore_manager_example/ have a index.html that doesn't work (I can't connect using http://yun.ip/keystore_manager_example but I can by adding /index.html)

/www/sd/ have a index.php that works properly (I can connect using http://yun.ip/sd/)

the uhttpd config:

        # Index file to use for directories, e.g. add index.php when using php
        list index_page         'index.html'
        list index_page         'index.php'

the command uci show uhttpd tells me:

uhttpd.main.index_page=index.html index.php

Why the index.html in the dir keystore_manager_example doesn't work ?

index_page is not a "list" option, so you can set only one. Easy trick is to always use index.html and it redirect to index.php when appropriate

No, I've played and googled around a bit, but seems like both index_file and index_page do not work as lists, so you can only specify one

OK I was able to achieve it by manually editing /etc/config/uhttpd, adding

list index_page index.htm index.html index.php

Notice the absence of both quotes and double quotes

However, this makes uci break with

uci: Parse error (too many arguments) at line 15, byte 37

so think twice about using it: it looks like uhttpd supports something uci doesn't :slight_smile:

From here: link

I read:

index_file	file name	no	index.html, index.htm, default.html, default.htm	Index file to use for directories, e.g. add index.php when using php
index_page	file name	no	index.html	Index file to use for directories, e.g. add index.php when using php (last, 20131015, replace index_file ?) should be noted: list index_page "index.html"

and if I put in my config file:

        # Index file to use for directories, e.g. add index.php when using php
        option index_page         'index.html'
        option index_page         'index.php'

the command uci show uhttpd tells me:

uhttpd.main.index_page=index.html index.php

infact i have a index**.php** in /sd that works! and the index**.html** in the /www that works also...the only one that doesn't work is the index.html in the /keystore_manager_example dir

To support both index.html and index.php same time:

uci set uhttpd.main.index_page='index.php index.html'
uci commit 
/etc/init.d/uhttpd restart
uci show uhttpd 
...
uhttpd.main.index_page=index.html index.php
...
nano /etc/config/uhttpd
...
option index_page 'index.html index.php'
...

The order of index.html index.php is very important, the last one has high high priority.

"index.html index.php" ; index.php shows first, if index.php is missing then shows index.html.
"index.php index.html"; index.html shows first.

@sonnyyu tried right now ! Same result...

http://yun.ip/ ==> open automatically http://yun.ip/cgi-bin/luci/webpanel/homepage

http://yun.ip/sd/ ==> open automatically the php files http://yun.ip/sd/index.php

but

http://yun.ip/keystore_manager_example/ ==> DOESN'T open the index.html file !! It returns the error "No such file or directory" ... I have to manually write:

http://yun.ip/keystore_manager_example/index.html for open the page !!!

It works for me.

after backup your own data,

/usr/bin/reset-to-factory-anyway

will bring your Yun back to factory default. then retry it.

sonnyyu:
The order of index.html index.php is very important, the last one has high high priority.

Ahh that what brought to think it wasn't working: I thought first had higher priority. Clear now, even if counter intuitive

Maybe too late but for everyone, I have The same problem and fix it.
If you need in webserver "uhttpd" run together html and php index :wink:
Here is oficial man: Web Server Configuration (uHTTPd) [Old OpenWrt Wiki]
Speed tutorial:

  • Must install PHP5:
    opkg update
    opkg install php5 php5-cgi

  • Must edit uhttpd config file
    vi /etc/config/uhttpd
    now must add 3 rows (lines)[without number & colon]:
    1:list interpreter '.php=/usr/bin/php-cgi'
    2:list index_page 'index.html, default.html, index.php'
    3:option index_file 'index.html, default.html, index.php'

  • And now just only restart uhttpd server:
    /etc/init.d/uhttpd restart

  • If you want can you control it:
    uci show uhttpd
    When you will see in uci list this 3 lines as:
    uhttpd.main.interpreter='.php=/usr/bin/php-cgi'
    uhttpd.main.index_page='index.html, default.html, index.php'
    uhttpd.main.index_file='index.html, default.html, index.php'

You're a winner :slight_smile: