.htaccess影响子域中的目录

时间:2015-02-06 04:14:22

标签: php apache .htaccess mod-rewrite laravel

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

我在我的网站上使用laravel

这是laravel结构

app/
bootstrap/
public/
vendor/
server.php

要从this answer

后面的网址中删除index.php和public

即,

在根路径中有.htaccess

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

这是我的.htaccess

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

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [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

始终显示内部服务器错误

我怎么能解决这个问题,例如对该目录有什么例外?

1 个答案:

答案 0 :(得分:8)

htaccess文件会影响文件所在的目录以及所有子目录。如果您有不希望mod_rewrite规则影响的子目录,那么您需要在子目录中添加一个htaccess文件并打开重写引擎(这样就不会有任何父规则具有优先权)。

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

RewriteEngine On