Q:

Htaccess some directory, subdirectory usage

I want rewriting "cat/" => x.php
"cat/sample-title" => y.php?t=$1 with htaccess.
I writed rewrite rules;
RewriteRule ^cat/ x.php [L]
RewriteRule ^cat/(.*)$ y.php?s=$1   [L]

but always cat/ rewriting to y.php?s=$1

A:

You're seeing two issues. The first is that both the first and second rules' patterns are matched by ^cat/, so the second one supplants the first after it is rewritten. You will need to anchor it with $, and also may want to permit an optional trailing / with /?.
Then, to differentiate it from the first, the second one must match one or more characters following the cat/, so instead of (.*), you should use (.+).
I would also change their order (though it is not strictly necessary in this case)
# Ensure one or more characters with .+
RewriteRule ^cat/(.+)$ y.php?s=$1 [L]
# Anchored with optional trailing /
RewriteRule ^cat/?$ x.php [L]

