调试 .htaccess 语法错误

Debug .htaccess syntax error

我有以下代码:

# Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^salom.dev[nc]
RewriteRule ^(.*)$ http://www.salom.dev/ [r=301,nc]

# 301 Redirect Entire Directory
RedirectMatch 301 /admin(.*) /vendor/aheinze/cockpit/

# Change default directory page
DirectoryIndex /site

# Prevent viewing of .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>

# Prevent directory listings
Options All -Indexes

我一直收到 500 条错误,但我找不到问题的任何想法?

这是配置文件:

<VirtualHost *:80>

        ServerAdmin webmaster@localhost
        ServerName salom.dev

        DocumentRoot /home/otis/Developer/salom
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /home/otis/Developer/salom/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

还有没有办法使用开发工具或可能的日志来调试这些错误?

DirectoryIndex 是一个文件而不是目录,您在 `[nc].

之前缺少 space

试试这个 .htaccess:

# Change default directory page
# DirectoryIndex /site

# Rewrite to www
Options +FollowSymLinks -Indexes
RewriteEngine on

RewriteCond %{HTTP_HOST} ^salom\.dev$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/ [R=301,L]

# 301 Redirect Entire Directory
RewriteRule ^admin(.*) /vendor/aheinze/cockpit/ [L,NC,R=301]

# Prevent viewing of .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>