Is it possible for me to add an htaccess rule for a search page so that it will work with and without query parameter. I ll add the example below
Actual file is www.mysite.com/search.php
Below 2 links should work for me
The rule I have added on htacess is given below
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^search/?$ search.php? [L]
RewriteRule ^search/([^/]+)$ search.php?query=$1 [L]
Any help will be much apprecited
2
Answers
Your current .htaccess rules are almost there, but you need to tweak them slightly to achieve the desired behavior.
here is a suggestion:
the QSA flag at the end means "query string append", which ensures that existing query parameters are preserved when adding title=loremipsum.