I am trying to use a rewirte rule in .htaccss so when a user enters “/page/my-name”, it will direct him to “file.php?name=my-name”
I use the following:
RewriteRule ^page/?$ file.php?name=1 [NC,L]
However, it redirects me only when I go to “/page” and not when i’m going to “/page/my-name”.
Your rule includes the
$anchor, meaning the request string has to end there. That is not actually what you want, since you want to capture anything after the/and use it in your substitution.Perhaps try something like this?
Also, note, you had
=1in your question, instead of=$1.