【发布时间】:2019-12-15 14:14:33
【问题描述】:
你好,我创建了一个小 cms 来学习 mvc,但我遇到了一个非常基本的问题。
通常我的域之后的整个 url 会显示在一个变量中,但如果我输入单词“index”我的变量是完全空的。
我的 index.php:
<?php
$url = $_GET['url];
echo $url;
?>
这是我的 .htaccess
RewriteEngine On
Options +FollowSymLinks
RewriteCond ${REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
所以如果我输入以下网址:
"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>
【问题讨论】:
标签: apache .htaccess mod-rewrite