我正在使用这个 htaccess 文件。除了第一个 RewriteRule 之外,一切都运行良好。当我打开 localhost/music/test/ 时,出现 404 not found 错误。当我打开 localhost/music/ 或 localhost/music/a/b/etc/ 时,它会正常工作。
任何人都知道我在这里做错了什么?
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\..+$
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^([^/]*)/$ /music/index.php?id=$1 [NC,L,QSA]
RewriteRule ^([^/]*)/([^/]*)/$ /music/index.php?id=$1&sid=$2 [NC,L,QSA]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/$ /music/index.php?id=$1&sid=$2&tid=$3 [NC,L,QSA]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ /music/index.php?id=$1&sid=$2&tid=$3&fid=$4 [NC,L,QSA]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ /music/index.php?id=$1&sid=$2&tid=$3&fid=$4&fiid=$5 [NC,L,QSA]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ /music/index.php?id=$1&sid=$2&tid=$3&fid=$4&fiid=$5&siid=$6 [NC,L,QSA]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ /music/index.php?id=$1&sid=$2&tid=$3&fid=$4&fiid=$5&siid=$6&seid=$7 [NC,L,QSA]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ /music/index.php?id=$1&sid=$2&tid=$3&fid=$4&fiid=$5&siid=$6&seid=$7&eiid=$8 [NC,L,QSA]
apache conf 或 virtualhost 能否将 htacces 文件破坏一行?
apache conf 是默认的 conf (apt-get apache2)
虚拟主机文件
<VirtualHost *:80>
ServerAdmin wouter1994_67@hotmail.com
ServerName sites
DocumentRoot /var/www/sites
<Directory /var/www/sites>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
注意:音乐目录在网站目录中