I have tried code given on under topic clean URLs using .htaccess, but it is nor working on my website.

Actually I am getting static content, but not getting parameters (dynamic content.) My .htaccess code is

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^user/([^/]+) /user.php?u=$1

My PHP file (user.php) is:

echo "ABC";
echo $_GET['u'];


My URL is:


(getting static contents , but not parameters)

  • Your URL has the "simran" directory in it but the rewrite rule does not. Have you tried putting that into your rewrite rule? Commented Feb 28, 2015 at 11:48

1 Answer 1


Easiest way is to Change:

RewriteRule ^user/([^/]+) /user.php?u=$1


RewriteRule ^simran/user/([^/]+) /user.php?u=$1 [L]

or for more flexibility you can use:

RewriteRule ^(.*)/user/([^/]+) /user.php?u=$2 [L]

That should make these URL's work


I changed $1 to $2 because $1 now points to contents before /user and you're interested in contents after /user. The .* means anything including nothing and punctuation.

In all cases, I always recommend suffixing a rule with an L in square brackets because it means don't process any further rules in the list after the rule is processed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.