I have this regex code:
RewriteCond %{REQUEST_URI} !/login([/]{0,1}) [NC]
RewriteCond %{REQUEST_URI} !/search/([/]{0,1}) [NC]
RewriteCond %{REQUEST_URI} !/search/([^.]+)([/]{0,1}) [NC]
RewriteRule ^([^.]+)/?$ products.php/$1/ [NC,L]
RewriteRule ^([^.]+)/([^.]+)/?$ products.php/$1/$2/ [NC,L]
RewriteRule ^login([/]{0,1})?$ login.php [NC,L]
RewriteRule ^search([/]{0,1})?$ search.php [NC,L]
RewriteRule ^search/([^.]+)/?$ search.php/$1/ [NC,L]
The problem is when i go to site/search/asdf regex redirects me to products.php file.
How can i fix this?
Aside from resorting your regexes, there’s no need for the
{0,1}:[/]{0,1}is exactly the same as/?. The?means: “Zero or one of the preceding element.”