Apache .htaccess如何显示;index.php“;在url中
你好,我创建了一个小cms来学习mvc,我有一个非常基本的问题 通常,我的域后的整个url都会显示在一个变量中,但如果我键入单词“index”,我的变量将完全为空 my index.php:Apache .htaccess如何显示;index.php“;在url中,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,你好,我创建了一个小cms来学习mvc,我有一个非常基本的问题 通常,我的域后的整个url都会显示在一个变量中,但如果我键入单词“index”,我的变量将完全为空 my index.php: <?php $url = $_GET['url]; echo $url; ?> 因此,如果我键入以下URL: “localhost/~username/mycms/indexabc”结果=>indexabc “localhost/~username/mycms/index”结果=> “l
<?php
$url = $_GET['url];
echo $url;
?>
因此,如果我键入以下URL:
“localhost/~username/mycms/indexabc”结果=>indexabc
“localhost/~username/mycms/index”结果=>
“localhost/~username/mycms/index.php”结果=>
“localhost/~username/mycms/index.php2”结果=>index.php2
有人知道我应该怎么做吗?我的.htaccess也会重定向index和index.php
我的httpd.conf文件:
<Directory "/Users/Sam/Sites/">
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
选项索引跟随符号链接多视图
允许超越所有
命令允许,拒绝
通融
要求所有授权
仅当下列条件适用时,才应用规则:
RewriteCond ${REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
条件意味着只有当URL不是现有的目录、文件或文件系统链接时,才会应用这些条件。我确信index.php文件存在,所以这就是localhost/~username/mycms/index.php
无法工作的原因
我认为在
mycms
目录中也存在名为index
的文件或目录。这可能是localhost/~username/mycms/index
不起作用的原因。我遵循了本教程,但在我的localhost上它不起作用
我的文件夹中有一个index.php
,但没有文件夹
这让我很困惑,因为我不明白我的本地主机出了什么问题
RewriteCond ${REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l