Conflict with Redirect to index.php and folder

Viewed 917

I rent an Apache web server. The folder architecture is like this:

  • root
    • src
    • template
    • less
    • www
      • css
      • js
      • jpeg

The web server serves only the www directory. And I use a .htaccess to redirect to HTTPS, remove the www. and redirect all request to the index.php except if a file exist in the www folder.

RewriteEngine On

# Redirect to HTTPS
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# Remove WWW
RewriteCond %{HTTP_HOST} ^www\.domaine\.com$ [NC]
RewriteRule (.*) https://domaine.com%{REQUEST_URI} [R=301,QSA,NC,L]

# Redirect all route to index.php
# Except the files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) /index.php?$1/ [NC,L,QSA]

The problem is the when I request a folder name. The folder is redirected twice to index.php!

Example: When I request http://domaine.com/css, the request is redirected to https://domaine.com/index.php?css/?css/.

How to solve the double redirect?

2 Answers
Related