.htaccess没有匹配的ifmodule?

ui7jx7zq  于 2023-02-19  发布在  其他
关注(0)|答案(1)|浏览(157)

我正在尝试使用Apache部署一个Laravel API,但是我不断收到“内部服务器错误”。在错误日志中,错误定义为“C:/Apache 24/htdocs/ErenA/public/.htaccess:没有匹配的部分”。我尝试更改.htaccess文件,删除httpd.conf中的ifmodule元素,并只保留“目录索引index.html index.php”,但似乎没有任何工作
下面是我.htaccess代码:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
    RewriteRule ^ index.php [L]
</IfModule>
    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

并且我还将添加httpd.conf ifModule:

<IfModule dir_module>
        DirectoryIndex index.php index.html
    </IfModule>

allowOverride是全部,并且要求在配置文件中授予全部权限。有人能帮帮我吗?

0pizxfdo

0pizxfdo1#

您有2个IfModule关闭(</IfModule>),但只有1个打开<IfModule dir_module>
所以你的内容应该是这样的:

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

看到我已经删除了中间的</IfModule>,因为您继续使用Rewrite模块(RewriteCondRewriteRule),我只是把它们放在里面...

相关问题