Htaccess rewrite adds "index.php" when I add a trailing slash to the address

I have an htaccess rewrite according to the following rules:

RewriteRule ^([a-zA-Z0-9\-]*)/([0-9]*)/([a-zA-Z0-9\-_]*)$ /content.php?a=$1&b=$2&c=$3 RewriteRule ^([a-zA-Z0-9\-]*)/([0-9]*)$ /content.php?a=$1&b=$2 RewriteRule ^([a-zA-Z0-9\-]*)$ /index.php?a=$1 

which works great when I go to the page "mydomain.com/nameofpage"

but when I add the trailing slash "mydomain.com/nameofpage/", the browser adds "index.php" to the end and 404 me.

Thoughts?

Thanks!

EDIT. It turned out .

it seems that my use of * in the first two rewrites exceeded my final rule ... the long story is short, here is the code that works correctly (changed * to + in three places):

 RewriteRule ^([a-zA-Z0-9\-]*)/([0-9]+)/([a-zA-Z0-9\-_]+)$ /content.php?a=$1&b=$2&c=$3 RewriteRule ^([a-zA-Z0-9\-]*)/([0-9]+)$ /content.php?a=$1&b=$2 RewriteRule ^([a-zA-Z0-9\-]*)$ /index.php?a=$1 
+4
source share
1 answer

Found out this - it seems that my use * in the first two rewrites exceeded my final rule ... the long story is short, here is the code that works correctly (changed * to + in three places):

RewriteRule ^([a-zA-Z0-9\-]*)/([0-9]+)/([a-zA-Z0-9\-_]+)$ /content.php?a=$1&b=$2&c=$3 RewriteRule ^([a-zA-Z0-9\-]*)/([0-9]+)$ /content.php?a=$1&b=$2 RewriteRule ^([a-zA-Z0-9\-]*)$ /index.php?a=$1

0
source

Source: https://habr.com/ru/post/1398210/


All Articles