I'm using this rewrite rule to redirect my search requests:
RewriteRule ^search/([^/\.]*)/([^/]+)/?$ index.php?search=$1&additional=$2 [L]
This rule works fine for
search/search/add
but it gives me a page not found for
search//add
(empty search)
What am I doing wrong? The regex should match:
Yes your regex will match search//add
but problem is that mod_rewrite
engine strips multiple slashes into single one in RewriteRule
directive.
You can use a RewriteCond
instead:
RewriteCond %{REQUEST_URI} ^/search/([^/.]*)/([^/]+)/?$ [NC]
RewriteRule ^ index.php?search=%1&additional=%2 [L,QSA]