apachemod_重写和php

apachemod_重写和php,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我有点小问题。 我在github上使用了简单的php框架,并对其进行了研究,添加了新函数等等 我得到帮助的框架是: 在MAMP环境中,一切都能完美工作,但现在,当我打算在一个实时网站和apache环境中测试它时,它的工作效果并没有那么好。 它显然可以读取索引文件,因为我将目录指向应该用于apache的目录 但是,当我要调用控制器(domain.com/login)时,它会导致apache给我: “未找到:在此服务器上未找到请求的URL/登录名。” 我已经使用服务a2enmod rewrite启

我有点小问题。 我在github上使用了简单的php框架,并对其进行了研究,添加了新函数等等

我得到帮助的框架是:

在MAMP环境中,一切都能完美工作,但现在,当我打算在一个实时网站和apache环境中测试它时,它的工作效果并没有那么好。 它显然可以读取索引文件,因为我将目录指向应该用于apache的目录

但是,当我要调用控制器(domain.com/login)时,它会导致apache给我:

“未找到:在此服务器上未找到请求的URL/登录名。”

我已经使用服务a2enmod rewrite启用了rewrite,在phpinfo()中查看时,我仔细检查了它,它是一个已加载的模块

位于“/var/www/html/php project/public”目录中的.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 webmaster@localhost
        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>

#ServerName指令设置请求方案、主机名和端口
#服务器用于标识自身。这在创建时使用
#重定向URL。在虚拟主机上下文中,服务器名
#指定必须在请求的主机:标头中显示的主机名
#匹配此虚拟主机。对于默认虚拟主机(此文件),此
#该值不是决定性的,因为它被用作最后的宿主。
#但是,必须为任何其他虚拟主机显式设置它。
服务器名www.domain.com
ServerAlias domain.com
服务器管理员webmaster@localhost
DocumentRoot/var/www/html/php项目/public
允许超越所有
#DocumentRoot/var/www/html
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
#包括conf available/service-cgi-bin.conf
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

选项如下符号链接
不允许超限
要求全部拒绝
不允许超限
要求所有授权
选项索引跟随符号链接
不允许超限
要求所有授权
#
#选项索引跟随符号链接
#不允许超限
#要求所有授权
#
AccessFileName.htaccess
我认为问题不在于php本身。 这就是为什么我没有添加我的代码,因为它有这么多的类,但正如我在问题开始时所说的,代码是基于框架的

你们中有人在conf中看到任何明显的问题吗? 我一直在寻找答案,但我似乎没有找到正确的答案。所以我真的非常感谢你的帮助。 有问题就继续问吧。
谢谢

请遵循apache2中访问重写模块的正确方式

首先使用以下命令在apache中启用重写模块-:

$ sudo a2enmod rewrite
打开apache2.conf文件

$ nano /etc/apache2/apache2.conf
更新该部分

<Directory /var/www/html/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>


请遵循apache2中访问重写模块的正确方式

首先使用以下命令在apache中启用重写模块-:

$ sudo a2enmod rewrite
打开apache2.conf文件

$ nano /etc/apache2/apache2.conf
更新该部分

<Directory /var/www/html/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>


判断
.htaccess
是否受到尊重的最简单方法是故意犯一个语法错误。如果出现500个服务器错误,那么从Apache的角度来看一切都正常。判断
.htaccess
是否受到尊重的最简单方法是故意犯一个语法错误。如果出现500个服务器错误,那么一切都正常从Apache的角度来看。