Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My site is written in PHP. I have changed its urls from php to html and reconvert it in .htaccess file.

I put autocomplete jquery ui widget in a page of my site and its call to remote file to get suggested items doesn't work. Because the remote url is changed to

search.html?term=spr

I put this line in htaccess file but it doesn't matche because it doesn't consider anything after \.html.

RewriteRule ^search\.html?term=([^-]+)$ search.php?term=$1 [L,NC,NS]

I also tried

RewriteRule ^search\.html\?term=([^-]+)$ search.php?term=$1 [L,NC,NS]

but both doesn't work.

Would you help me?
Thank you.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You need to tell Apache to append the query string (QSA = Query string append)

 RewriteRule ^search\.html$ search.php [L,NC,NS,QSA]

^search\.html$ is a regular expression matching a literal search.html. ^ matches from the beginning, $ matches till the end and \. matches a literal dot instead of any character (the special meaning of a dot in regular expressions)

This rule...

  • Matches a request for search.html (RewriteRule ^search\.html$)
  • and rewrites it to search.php,
  • processing no rules after this one ([L]),
  • match case insensitive (e.g. Search.HTML would be rewritten too) ([NC])
  • will not be used for subrequests ([NS])
  • and will finally append the original Query string after search.php ([QSA])

For an overview of flags:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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