Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7817171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:08:43+00:00 2026-06-02T06:08:43+00:00

I am using this htaccess file. Everything is working fine except that first RewriteRule.

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:08:47+00:00Added an answer on June 2, 2026 at 6:08 am

    RewriteCond directives only affect the first immediate RewriteRule, so the 3 conditions you have:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !\..+$
    RewriteCond %{REQUEST_URI} !/$
    

    Are only applied to the first rule:

    RewriteRule ^([^/]*)/$ /music/index.php?id=$1 [NC,L,QSA]
    

    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:

    RewriteCond %{REQUEST_URI} !^\..+$
    RewriteCond %{REQUEST_URI} !^/$
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using HTML5 BP's .htaccess file unedited. Everything works fine until I add my
I'm using this .htaccess file: RewriteEngine on RewriteCond %{REQUEST_URI} .(html|php)$ [OR] RewriteCond -d RewriteRule
I'm having trouble with redirecting urls using the .htaccess file. This is what my
I am using this htaccess file on my site to remove index.php. RewriteEngine on
I'm using jquery address and everything is working great except for one small issue
I am using this rule into my .htaccess to redirect IE 6 and 7
Using this file as source, I have a situation where I need to retrieve
Using this xslt file found on this blog to pretty print xml using Nokogiri,
I am using .htaccess and mod_rewrite in my little PHP framework. It's working nicely,
So, i have my .htaccess, my controllers, everything is going fine. I added localization,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.