I want to enable my users to enter search queries using a URL like this:
http://www.domain.com/searchterm
or with a trailing slash like this:
http://www.domain.com/searchterm/
However, I want to capture certain search terms and redirect them to an actual directory. For example, a query like this:
http://www.domain.com/css/site.css
should actually point to the CSS file, and should not pass “css/site.css” as the search term.
Here’s my non working code:
RewriteRule ^/(.+)/?$ /index.php?search=$1 [L]
RewriteRule ^/css/(.+)$ /css/$1 [L]
This doesn’t work – can anyone tell me what I’m doing wrong?
Instead of excluding all your existing urls it would be a far better solution to use a script like thia as a 404 page. While capturing the 404 you could still send a 200 response but atleast it would make your rewrite rules far easyer.
Or if you really want to do it without the 404, use this