Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XAMPP或live网站都不会自动呈现index.php_Php_.htaccess - Fatal编程技术网

XAMPP或live网站都不会自动呈现index.php

XAMPP或live网站都不会自动呈现index.php,php,.htaccess,Php,.htaccess,自从我在我的根文件夹中添加了一个.htaccess文件(至少在那时我开始注意到有问题)以来,我的根文件夹中包含以下内容: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php [NC,L] 我的网站从未自动登陆index.php文件。要查看实时结果,请执行以下操作: www.unidrones.co.za/cho

自从我在我的根文件夹中添加了一个.htaccess文件(至少在那时我开始注意到有问题)以来,我的根文件夹中包含以下内容:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
我的网站从未自动登陆index.php文件。要查看实时结果,请执行以下操作: www.unidrones.co.za/choicegeline

页面应该呈现index.php文件并自动突出显示“HOME”链接,就像我在URL中手动键入index.php一样:www.unidrones.co.za/choicegeline/index.php

首先,它正在读取索引文件内容,但与之相关联的CSS不起作用。每个页面都动态添加了一个body ID,因此索引文件的body标记的ID为#index

我在SO和其他论坛上进行了研究,发现了类似的问题,并在试用时检查了所有问题:

  • 编辑Apache配置文件(检查)
  • 从allowOverrite All(选中)中删除#注释
  • 在cPanel上编辑htaccess文件(选中)
  • 删除htaccess文件(选中)
  • 将DirectoryIndex.php放在.htaccess文件中(选中)
  • 这个问题很接近,但仍然不适用
  • 其他一些不值得一提的解决方案(全部选中)

  • 上述解决方案都不起作用。我在XAMPP和live上尝试了该站点,但两个站点都没有像昨天一样正常显示。

    使用以下内容在您的根目录中添加index.php:

    <?php
    header('Location: ' . ('http://www.unidrones.co.za/ChoiceGelatin/index.php'));
    ?>
    
    
    

    这会将您重定向到ChoiceAgreen的索引页面。.htaccess中的重写规则实际上消除了每次请求php文件时添加
    .php
    的负担。但它似乎不起作用,可能是因为http.conf中的配置

    您在apache http.conf文件中启用了mod_rewrite吗?httpd.conf文件中唯一的mod_rewrite行是这样的,它没有被注释掉,所以我假设它已启用:LoadModule rewrite_module modules/mod_rewrite。so@ArabianMaiden两个链接呈现相同的php文件。php
    scripts.php
    中的javascript负责样式设置(具体来说,这里的类
    ),这是一个合理的解决方法,但是我需要知道我做错了什么,因为直到昨天,一切都正常工作。。。将来我更希望不要使用header()函数,而是让它按它的方式工作should@ArabianMaiden嗯,我不确定。也许您有一个不同的.htaccess文件,可以正确地将任何url重定向到正确的locaton并将其删除。或者你以前也有索引页?