.htaccess 影响子域中的目录

.htaccess affects directory in the sub domains

考虑这是我的域www.example.com

我正在我的网站中使用 laravel

这是laravel结构

app/
bootstrap/
public/
vendor/
server.php

要从 url 中删除 index.php 和 public 我遵循了 this answer

在根路径中有 .htaccess

并将 server.php 文件重命名为 index.php

这是我的 .htaccess

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ / [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

效果很好,但问题是我的子域为

projects.example.com

虽然我在这里创建了一个子目录,即

projects.example.com/firstproject

总是显示内部服务器错误

我该如何解决这个问题,比如那个目录或类似的东西有例外?

htaccess 文件影响文件所在的目录和所有子目录。如果您有不希望 mod_rewrite 规则影响的子目录,那么您需要在重写引擎打开的子目录中添加一个 htaccess 文件(以便 none 的父规则具有优先级)。

只需将其添加到您子目录中的 htaccess 文件中,无需任何实际规则:

RewriteEngine On