简体   繁体   English

行动版Chrome主萤幕网路应用程式无法开启index.php

[英]Mobile Chrome home-screen webapp won't open index.php

I've got a single webapp in a html/php file called index.php along with JS and CSS files. 我在一个名为index.php的html / php文件以及JS和CSS文件中只有一个webapp。 When you type in my domain, it will load the index.php file just like it normally would, but I would like for users to add this to their home-screen to use like an app. 当您输入我的域时,它将像往常一样加载index.php文件,但我希望用户将其添加到主屏幕中,以像应用程序一样使用。

So on my Android phone, running Lollipop, when I added it to my home-screen and I click on it, it will say it didn't find index. 因此,在运行Lollipop的Android手机上,当我将其添加到主屏幕并单击时,它会说它找不到索引。 html , not index.php like it should be looking for. html ,而不是应该寻找的index.php。

My web server is a Rackspace VPS running apache2. 我的Web服务器是运行apache2的Rackspace VPS。 I tried looking in the conf file for apache, but didn't see anything obvious as to how to make it go to index.php. 我尝试在conf文件中查找apache,但没有发现任何明显的方法来使它进入index.php。

So my temporary solution for this was to make an index.html that redirects to index.php on the same level. 因此,我的临时解决方案是在同一级别上创建一个index.html并重定向到index.php。 I've encountered a few bugs that were not there before I changed it to a .php file instead of .html on the home-screen webapp side. 在将其更改为.php文件而不是主屏幕webapp端的.html之前,我遇到了一些错误。

The only thing I'm using the php for is cookies management and detecting first-time users, so I really could drop the php and go with JS instead, but I like PHP a whole lot more so I would like to stick with that. 我唯一使用php的是cookie管理和检测首次使用的用户,因此我真的可以删除php并改为使用JS,但是我非常喜欢PHP,因此我愿意坚持。

Thanks for any help in advance! 感谢您的任何帮助!

Here's a screenshot of what opening the home-screen bookmark gets on Android. 是打开主屏幕书签在Android上获得的屏幕截图

You can get that done by creating a .htaccess file, in the same directory as index.php 您可以通过在与index.php相同的目录中创建.htaccess文件来完成此操作

Just create a file called .htaccess (make sure you have hidden files enabled on your machine) and add the following line and save: 只需创建一个名为.htaccess的文件(确保已在计算机上启用了隐藏文件),然后添加以下行并保存:

DirectoryIndex index.php DirectoryIndex index.php

This basically redirects domain.com/ to domain.com/index.php (without changing the way the url looks in the address bar) 基本上,这会将domain.com/重定向到domain.com/index.php(而不更改网址在地址栏中的显示方式)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM