I am using this htaccess file. Everything is working fine except that first RewriteRule.
When I open localhost/music/test/ I get a 404 not found error.
When I open localhost/music/ or localhost/music/a/b/etc/ it works like it should.
Anyone knows what I am doing wrong here?
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]
Could the apache conf or the virtualhost break the htacces file for one line?
apache conf is the default conf (apt-get apache2)
virtualhost file
<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>
Note: the music dir is inside the sites dir
RewriteConddirectives only affect the first immediateRewriteRule, so the 3 conditions you have:Are only applied to the first rule:
And all the other rules aren’t bound by those 3 conditions. The reason why the first rule probably never gets applied is because you have the condition:
%{REQUEST_URI} !/$which says if the URI does not end with a slash. But the rule itself requires that the URI ends with a slash (^([^/]*)/$). I’m going to assume that your conditions are missing a^in front of them and that you meant:As in, does not start with a . and is not a /. You’ll also want to duplicate those conditions for each of the RewriteRule entries that you have if you want them to also be applied to the other rules.