我正在尝试通过Apache中的.htaccess设置创建一个安静的URL(默认安装在Yosemite中。
这是我的设置
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L]
当我在浏览器中输入“http://localhost/~jokerham/API/user”时, 我收到一条错误消息
Not Found
The requested URL /Users/jokerham/Sites/API/index.php was not found on this server.
但是当我在终端中检查文件时,该文件存在。
hamdong-gyun-ui-MacBook-Air:API jokerham$ pwd
/Users/jokerham/Sites/API
hamdong-gyun-ui-MacBook-Air:API jokerham$ ls
index.php
为什么我的.htaccess设置出错?
答案 0 :(得分:1)
也许在API目录中以这种方式尝试您的规则
RewriteEngine On
RewriteBase /~jokerham/API
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ index.php [L]