This should work, I tested it with different names and directories, but it should be fine in your case.
NB: for the matched group from RewriteCond you must use %1 not $1 .
RewriteCond %{QUERY_STRING} ^s=([az]+)$ [NC] RewriteRule ^$ /s/%1? [NC,R,L] RewriteRule ^s/([az]+)$ /?s=$1 [NC,L]
Edit for debugging (see comments):
my test:
| / | --> doc | | | --> doc.php (takes doc as GET parameter) | | index.php
My apache rewrite
RewriteCond %{QUERY_STRING} ^doc=([az]+)$ [NC] RewriteRule ^$ /doc/%1? [NC,R,L] RewriteRule ^doc/([az]+)$ /doc/doc.php?doc=$1 [NC,L]
Then the query for domain.com/?doc=query displays the doc is query
It works for me.
M'vy
source share