我有一个轻微的问题。 我在github上使用了简单的php框架,并对它进行了处理并添加了新的功能等等。Apache mod_rewrite和php
我有帮助的框架是这样的: https://github.com/panique/mini
一切完美的作品在一个MAMP环境,但现在,当我要测试它在实时网站和Apache环境这是行不通的那好。 它显然可以读取索引文件,因为我将目录指向应该用于apache的目录。
但是,当我要去做出一个控制器(domain.com/login)的调用它产生的apache给我:
“未找到:请求的URL /登陆此服务器上找到。 “
我已经启用重写:服务a2enmod重写,我重复检查,它是一个加载模块时,在phpinfo()中查找。
是位于“的/ var/www/html等/ PHP项目/公共”目录(其中我已经指出,在我的虚拟主机文件”。 .htaccess文件如下:
# Necessary to prevent problems when using a controller named "index" and having a root index.php
Options -MultiViews
# Activates URL rewriting
RewriteEngine On
# Prevent people from looking directly into folders
Options -Indexes
# If the following conditions are true, then rewrite the URL:
# If the requested filename is not a directory,
RewriteCond %{REQUEST_FILENAME} !-d
# and if the requested filename is not a regular file that exists,
RewriteCond %{REQUEST_FILENAME} !-f
# and if the requested filename is not a symbolic link,
RewriteCond %{REQUEST_FILENAME} !-l
# then rewrite the URL in the following way:
# Take the whole request filename and provide it as the value of a
# "url" query parameter to index.php. Append any query string from
# the original URL as further query parameters (QSA), and stop
# processing this .htaccess file (L).
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
00 default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName www.domain.com
ServerAlias domain.com
ServerAdmin [email protected]
DocumentRoot /var/www/html/php-project/public
<Directory />
AllowOverride All
</Directory>
#DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
的apache.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
#<Directory /srv/>
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#</Directory>
AccessFileName .htaccess
我不认为在p roblem是在php本身之内的。 这就是为什么我没有添加我的代码,因为它的类太多了,但代码正如我在问题开始时基于框架所说的那样。
你们中的任何人看到conf中有任何明显的问题吗? 我已经搜索并搜索了答案,但我似乎没有把它做对。所以我真的很感激一些帮助。 如有任何疑问,请询问。 谢谢
这最简单的方法,以确定是否'.htaccess'甚至荣幸是要故意语法错误。如果你得到500服务器错误,那么从Apache的角度来看,一切都是可行的。 –