.htaccess keeps replacing URI with index.php

36 views Asked by At

We have made a flyer were a URL is printed at which looks like this:

mycompany.de/special

But if a user actually enters this URL, then he is getting redirected to the startpage https://www.mycompany.de/index.php instead of getting redirected to https://www.mycompany.de/special

This is my .htaccess so far, it forces https and www:

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

That works almost as expected, the only problem is that /special is getting removed and replaced by /index.php. The question is, why is special getting replaced?

1

There are 1 answers

0
Black On

I was able to solve it with this code:

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteCond %{REQUEST_URI} !^/special
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php/%{REQUEST_URI} [L]