Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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
.htaccess不适用于PHP_Php_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess不适用于PHP

.htaccess不适用于PHP,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,.htaccess不响应重写规则。我已经在项目的根目录下创建了一个.htaccess文件,并用以下条件填充了它 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)& index.php?url=1 [NC, L] 但是当我在index.php中执行下面

.htaccess不响应重写规则。我已经在项目的根目录下创建了一个.htaccess文件,并用以下条件填充了它

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)& index.php?url=1 [NC, L]
但是当我在index.php中执行下面的代码时,得到的是false而不是true

<?php
 var_dump(isset($_GET["url"]));
我从主目录中的文件夹运行服务器,而不是
/var/www/html

另外,当我访问站点的任何部分
localhost:8000/fishes
时,它仍然加载
index.php
,并显示
false

我一直在努力解决这个问题,但没有任何效果,请帮助大家,我可能做错了什么。

试试这个:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule (.+) index.php?url=1 [NC, L]

另外,将
目录/
定义替换为以下内容:

<Directory />
    Options Indexes FollowSymLinks -MultiViews
    AllowOverride All
    Require All Granted
    Allow from all
</Directory>

它不工作的原因是因为我在apache/var/www/directory之外运行PHP,显然,如果我想让它在那里工作,我必须从
/etc/apache2/apache2.conf

设置它,请求的URL中是否有符号和?你可能想要
url=$1
而不是
url=1
@chris85不,不是真的,我想做的只是得到数字1并显示出来,我用它来测试是否没有一个符号比这个
^(.+)&
不匹配。如果你不在乎找到的值,那么你就不需要
()
@chris85,哦,谢谢,我刚刚添加了符号,仍然不起作用重写工作吗?不走运,我想知道问题可能是什么,我从午餐开始就在这个问题上根据编辑尝试新的选项集:
-多视图
好的,谢谢Inigo Flores,非常感谢,创建虚拟主机并将我的文件转储到/var/www/dev.com/public_hmtl下后,.htaccess开始工作,但不在该目录之外
<Directory />
    Options Indexes FollowSymLinks -MultiViews
    AllowOverride All
    Require All Granted
    Allow from all
</Directory>
chmod a+x /home/myhome