I created a search form for my website with search engine friendly urls.
I have the following form code on every page of my website :
<form class="form" method="get" id="searchform" action="searchrd">
Search
Here is also my htaccess file :`
RewriteCond %{QUERY_STRING} ^query=([^&]+)$ [NC]
RewriteRule ^searchrd/?$ /musique/%1.html? [R=301,L,NC,NE]
RewriteRule ^/?musique/([^&]+).html?$ musique.php?query=$1 [NC,L,QSA]
My problem is the following :
When a user searches for a query with a slash or & for example it gives me a 404 error. I want the slash and & to be removed in order to have a workign search. How can I solve this problem? I think it might be related to regex.
Try the [B]
flag
RewriteRule ^/?musique/([^&]+).html?$ musique.php?query=$1 [NC,L,QSA,B]
The [B] flag instructs RewriteRule to escape non-alphanumeric characters before applying the transformation.