Apache mod_rewrite: path replaced with query string

29 views Asked by At

I have the following rule:

RewriteRule ^/([0-9]+)/([a-z0-9_-]*)\.([a-z]+)$ index.php?id=$2&type=$3&size=$1 [R=301,L]

The problem is that when I go to the URL /0/azerty.ext in a browser the URL is displayed as /index.php?id=azerty&type=ext&size=0. What I want is the redirection to be performed, with /0/azerty.ext as the visible URL.

I tried to remove the R=301 flag, but in that case the redirection is not performed.

What am I missing?

1

There are 1 answers

0
gregseth On BEST ANSWER

Found a solution (adding slash at the beginning of the redirected URL), not sure why though...

RewriteRule ^/([0-9]+)/([a-z0-9_-]*)\.([a-z]+)$ /index.php?id=$2&type=$3&size=$1 [L]