I couldn't find the good duplicate (there are tons of questions about this) and in a good mood, so here we go:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^dice_mpc/(.+)/(.+)$ dice_mpc/$1.php?as=$2 [QSA,L]
</IfModule>
DETAILS:
RewriteCond %{REQUEST_FILENAME} !-d
will prevent rewriting if you access to an existing folder
RewriteCond %{REQUEST_FILENAME} !-f
will prevent rewriting if you access to an existing file
RewriteRule ^dice_mpc/(.+)/(.+)$ dice_mpc/$1.php?as=$2 [QSA,L]
will rewrite only URLS of format {domain}/dice_mpc/{A}/{B}
so it won't redirect if {B}
is not there. {A}
will be converted to {A}.php
and {B}
to ?as={B}
QSA
means query strings will be preserved ({domain}/dice_mpc/{A}/{B}?test=1
will be rewritten to {domain}/dice_mpc/{A}.php?as={B}&test=1
), and L
means rewriting will stop here
- Don't forget to change your links to the new format, and be aware it may interact if you have other rewrite rules in your
.htaccess
If this is not exactly what you want, please edit the question itself.