I need to rewrite URL like http://www.example.com/search.php?abc
to http://www.example.com/abc
using the rules below, but it doesn’t work, why doesn’t it match?
RewriteCond %{REQUEST_URI} ^search.php
RewriteRule ^search.php?q=([-0-9a-zA-Z]+) $1
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
%{REQUEST_URI}always has a/at the start. soRewriteCond %{REQUEST_URI} ^search.phpwill never match.RewriteRule Directive
?means match for one or none of previous character when not escaped. So your^search.php?q=...would match:search.phpq=...search.phq=...from PCRE man pages
You will have to do this:
NC(nocase) : flag_nc Apache DocsL(last) : flag_l Apache Docs