RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/specialities/([0-9]+)/([^/.]+)$ speciality_details.php?id=$1&name=$2 [NC,L]
Just as in the first rule (which is "working"), you should not be matching a slash prefix on the URL-path. And the preceding condition (RewriteCond
directive) is superfluous, since a URL of the form /specialities/23/ent
could not possibly match a physical file (could it?).
In .htaccess
, the URL-path matched by the RewriteRule
pattern does not start with a slash since the directory-prefix (that always ends with a slash) has already been removed.
So, the rule should look like the following instead (and no RewriteCond
directive):
RewriteRule ^specialities/([0-9]+)/([^/.]+)$ speciality_details.php?id=$1&name=$2 [NC,L]
This would match a URL of the form example.com/specialities/23/ent
, as per your example. And assumes the file being rewritten to is speciality_details.php
in the document root.
The NC
(nocase
) flag should also be superfluous, unless you are expecting mixed case versions of sPeCiAlItIeS
? But if you are then that is better resolved with a redirect since the rewrite would potentially result in a duplicate content (SEO) issue.
Make sure you clear your browser cache before testing.
Although, from your earlier question edits it looks like you had already tried this without the slash prefix, but at the time you had /speciality/23/ent
, not /specialities/23/ent
as the example request URL - which would obviously not match.