I want to use the "tit" parameter as the main part of the URL.
If you literally only want to use that one parameter, and you don't need to pass the other parameters in the URL (ie. they can be deduced from that one parameter), then it's exactly the same as your first example. You would have a "pretty" (fake) URL of the form:
(No need for the
.php extension on the URL, unless you explicitly want it?) Which is then internally rewritten with something like the following in the
RewriteRule ^([\w-]+)$ keyboard-chart.php?gam=141&sty=16&lay=1&tit=$1 [L]
In the above example, the
lay parameters are hard-coded in the
RewriteRule substitution. This assumes that given a
tit parameter of
sid-meiers-alpha-centauri-smac-1, you know what these other parameter values are.
However, if that is not the case and these other parameters can also vary, then these must also be passed in the "pretty" URL, since they cannot be deduced from the single
tit parameter. This can be achieved using the same principle as above: define a capturing group (ie. parenthesised sub pattern) in the
RewriteRule pattern (regex) for each parameter and use a corresponding backreference (
$9) in the substitution. For example, given a URL of the form:
Then this can be internally rewritten with something like the following in the
RewriteRule ^(\d+)/(\d+)/(\d)/([\w-]+)$ keyboard-chart.php?gam=$1&sty=$2&lay=$3&tit=$4 [L]
coming from "fake" URLs
I know what you mean, but they aren't really fake. They are the "pretty" URLs, or simply "URLs". It's just that they don't directly map to a file system resource, without some URL rewriting. (By "fake" I immediately thought you were referring to URLs that didn't exist!)
SEO Friendly URLs
The article that you link to makes repeated reference to "SEO friendly URLs". To be clear, these are not strictly SEO-friendly. Search engines don't really care. "Pretty" URLs like this are primarily for the benefit of users, not search engines, and can help with click-through rates, but they don't directly help with ranking.