Cuelogic Blog Icon
Cuelogic Career Icon
Home > Blog > Product Development > Web > QueryString in .htaccess – Match Question Mark in rewrite rule

QueryString in .htaccess – Match Question Mark in rewrite rule

I am changing my development structure to have rewrite urls for fuse/action and I thought it’s cool if I represent all URLs like google (

so should look like

for this purpose I have first tried a simple rule to match anything after “/”.

RewriteEngine On

RewriteRule ^(.*)$ index.php?action=$1 [L]

but when I print GET variables then it s only giving me the part before “?” (that was strange)

Then after googling a bit I just got the hint that Mod Rewrite do not matches string after “?” because it’s treating it as %{QUERYSTRING} , hence I have created following rule to achieve the result which is running perfect for me

RewriteEngine On

RewriteRule ^/?([^/][^\./]*)[:;,\.]*$ index.php?action=$1&%{QUERY_STRING} [L]

Post originally taken from

Apache url mod_rewrite